Use the blurHash if available, when the thumbnailSource is null, and if not available render the image icon for image file.
This commit is contained in:
parent
4d48005f3d
commit
d2483ea11a
1 changed files with 15 additions and 1 deletions
|
|
@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.GraphicEq
|
import androidx.compose.material.icons.outlined.GraphicEq
|
||||||
|
import androidx.compose.material.icons.outlined.Image
|
||||||
import androidx.compose.material.icons.outlined.VideoCameraBack
|
import androidx.compose.material.icons.outlined.VideoCameraBack
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
|
@ -57,12 +58,26 @@ fun AttachmentThumbnail(
|
||||||
contentScale = ContentScale.Crop,
|
contentScale = ContentScale.Crop,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
)
|
)
|
||||||
|
} else if (info.blurHash != null) {
|
||||||
|
BlurHashAsyncImage(
|
||||||
|
model = null,
|
||||||
|
blurHash = info.blurHash,
|
||||||
|
contentDescription = info.textContent,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = modifier,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier.background(backgroundColor),
|
modifier = modifier.background(backgroundColor),
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
when (info.type) {
|
when (info.type) {
|
||||||
|
AttachmentThumbnailType.Image -> {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Outlined.Image,
|
||||||
|
contentDescription = info.textContent,
|
||||||
|
)
|
||||||
|
}
|
||||||
AttachmentThumbnailType.Video -> {
|
AttachmentThumbnailType.Video -> {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.VideoCameraBack,
|
imageVector = Icons.Outlined.VideoCameraBack,
|
||||||
|
|
@ -93,7 +108,6 @@ fun AttachmentThumbnail(
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else -> Unit
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue