From 65c6da148071fb48bb96ddcbcf656024dbecfff9 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 8 Nov 2023 15:34:06 +0100 Subject: [PATCH] Use the blurHash if available, when the thumbnailSource is null, and if not available render the image icon for image file. --- .../matrix/ui/components/AttachmentThumbnail.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/AttachmentThumbnail.kt b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/AttachmentThumbnail.kt index c1fa34a764..615ebfdf2d 100644 --- a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/AttachmentThumbnail.kt +++ b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/AttachmentThumbnail.kt @@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.GraphicEq +import androidx.compose.material.icons.outlined.Image import androidx.compose.material.icons.outlined.VideoCameraBack import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable @@ -57,12 +58,26 @@ fun AttachmentThumbnail( contentScale = ContentScale.Crop, modifier = modifier, ) + } else if (info.blurHash != null) { + BlurHashAsyncImage( + model = null, + blurHash = info.blurHash, + contentDescription = info.textContent, + contentScale = ContentScale.Crop, + modifier = modifier, + ) } else { Box( modifier = modifier.background(backgroundColor), contentAlignment = Alignment.Center ) { when (info.type) { + AttachmentThumbnailType.Image -> { + Icon( + imageVector = Icons.Outlined.Image, + contentDescription = info.textContent, + ) + } AttachmentThumbnailType.Video -> { Icon( imageVector = Icons.Outlined.VideoCameraBack, @@ -93,7 +108,6 @@ fun AttachmentThumbnail( modifier = Modifier.fillMaxSize() ) } - else -> Unit } } }