feat: Enhance ImageAttachment placeholder with gradient background and improved blurhash logging

This commit is contained in:
k1ngsterr1
2026-01-25 18:05:34 +05:00
parent 1d36b51d06
commit 2bb754081b

View File

@@ -22,6 +22,7 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.drawscope.Stroke
@@ -172,14 +173,22 @@ fun ImageAttachment(
}
// Декодируем blurhash для placeholder (если есть)
if (preview.length >= 20) {
if (preview.isNotEmpty() && !isDownloadTag(preview)) {
withContext(Dispatchers.IO) {
try {
Log.d(TAG, "🎨 Decoding blurhash: ${preview.take(30)}... (length: ${preview.length})")
blurhashBitmap = BlurHash.decode(preview, 200, 200)
if (blurhashBitmap != null) {
Log.d(TAG, "✅ Blurhash decoded successfully")
} else {
Log.w(TAG, "⚠️ Blurhash decode returned null")
}
} catch (e: Exception) {
Log.e(TAG, "Failed to decode blurhash: ${e.message}")
Log.e(TAG, "Failed to decode blurhash: ${e.message}", e)
}
}
} else {
Log.d(TAG, "⚠️ No valid blurhash preview (preview='${preview.take(20)}...', isDownloadTag=${isDownloadTag(preview)})")
}
// Декодируем изображение если уже скачано
@@ -318,11 +327,18 @@ fun ImageAttachment(
)
}
else -> {
// Простой placeholder
// Простой placeholder с приятным gradient фоном
Box(
modifier = Modifier
.fillMaxSize()
.background(if (isDarkTheme) Color(0xFF2A2A2A) else Color(0xFFE8E8E8))
.background(
Brush.verticalGradient(
colors = if (isDarkTheme)
listOf(Color(0xFF2A2A2A), Color(0xFF1A1A1A))
else
listOf(Color(0xFFE8E8E8), Color(0xFFD0D0D0))
)
)
)
}
}