fix: continue not to animate avatars
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
872940900a
commit
bcfdcd6496
|
|
@ -21,17 +21,18 @@ fun RemoteImage(
|
|||
modifier: Modifier = Modifier,
|
||||
contentScale: ContentScale = ContentScale.Crop,
|
||||
width: Int = 0,
|
||||
height: Int = 0
|
||||
height: Int = 0,
|
||||
allowAnimation: Boolean = true
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
|
||||
fun pxAsDp(px: Int): Dp {
|
||||
return (
|
||||
px / (
|
||||
context.resources
|
||||
.displayMetrics.densityDpi.toFloat() / DisplayMetrics.DENSITY_DEFAULT
|
||||
)
|
||||
).dp
|
||||
px / (
|
||||
context.resources
|
||||
.displayMetrics.densityDpi.toFloat() / DisplayMetrics.DENSITY_DEFAULT
|
||||
)
|
||||
).dp
|
||||
}
|
||||
|
||||
GlideImage(
|
||||
|
|
@ -41,6 +42,9 @@ fun RemoteImage(
|
|||
modifier = modifier
|
||||
.width(pxAsDp(width))
|
||||
.height(pxAsDp(height)),
|
||||
transition = CrossFade
|
||||
transition = CrossFade,
|
||||
requestBuilderTransform = { rb ->
|
||||
if (!allowAnimation) rb.dontAnimate() else rb
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ fun UserAvatar(
|
|||
size: Dp = 40.dp,
|
||||
presenceSize: Dp = 16.dp,
|
||||
shape: Shape = RoundedCornerShape(LoadedSettings.avatarRadius),
|
||||
allowAnimation: Boolean = false,
|
||||
onLongClick: (() -> Unit)? = null,
|
||||
onClick: (() -> Unit)? = null
|
||||
) {
|
||||
|
|
@ -104,6 +105,7 @@ fun UserAvatar(
|
|||
url = rawUrl ?: "$REVOLT_FILES/avatars/${avatar.id}",
|
||||
contentScale = ContentScale.Crop,
|
||||
description = stringResource(id = R.string.avatar_alt, username),
|
||||
allowAnimation = allowAnimation,
|
||||
modifier = Modifier
|
||||
.clip(shape)
|
||||
.size(size)
|
||||
|
|
@ -123,6 +125,7 @@ fun UserAvatar(
|
|||
RemoteImage(
|
||||
url = "$REVOLT_BASE/users/${userId.ifBlank { "0".repeat(26) }}/default_avatar",
|
||||
description = stringResource(id = R.string.avatar_alt, username),
|
||||
allowAnimation = allowAnimation,
|
||||
modifier = Modifier
|
||||
.clip(shape)
|
||||
.size(size)
|
||||
|
|
|
|||
Loading…
Reference in New Issue