feat: Add loading of blur preview for images in ZoomableImage component

This commit is contained in:
k1ngsterr1
2026-01-28 01:14:29 +05:00
parent 29b023c39f
commit a8f5ae63fd

View File

@@ -300,6 +300,7 @@ private fun ZoomableImage(
val scope = rememberCoroutineScope()
var bitmap by remember { mutableStateOf<Bitmap?>(null) }
var previewBitmap by remember { mutableStateOf<Bitmap?>(null) }
var isLoading by remember { mutableStateOf(true) }
var loadError by remember { mutableStateOf<String?>(null) }
@@ -331,6 +332,21 @@ private fun ZoomableImage(
val minScale = 1f
val maxScale = 5f
// Load preview first
LaunchedEffect(image.preview) {
withContext(Dispatchers.IO) {
try {
// Декодируем blur preview (после ::)
if (image.preview.contains("::")) {
val blurPart = image.preview.substringAfter("::")
previewBitmap = base64ToBitmapSafe(blurPart)
}
} catch (e: Exception) {
Log.e(TAG, "Failed to load preview: ${e.message}")
}
}
}
// Load image
LaunchedEffect(image.attachmentId) {
isLoading = true
@@ -514,6 +530,16 @@ private fun ZoomableImage(
},
contentAlignment = Alignment.Center
) {
// Blur preview в фоне
if (previewBitmap != null && bitmap == null) {
Image(
bitmap = previewBitmap!!.asImageBitmap(),
contentDescription = "Preview",
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Fit
)
}
when {
isLoading -> {
CircularProgressIndicator(