Set avatar size value to dp

This commit is contained in:
Florian Renaud
2023-03-14 15:23:29 +01:00
parent 91deab3b97
commit d04aae9475
4 changed files with 11 additions and 11 deletions

View File

@@ -222,7 +222,7 @@ fun CreateRoomSearchResultItem(
MatrixUserRow(
modifier = modifier.heightIn(min = 56.dp),
matrixUser = matrixUser,
avatarSize = AvatarSize.Custom(36),
avatarSize = AvatarSize.Custom(36.dp),
onClick = onClick,
)
}

View File

@@ -94,7 +94,7 @@ private fun InitialsAvatar(
Text(
modifier = Modifier.align(Alignment.Center),
text = avatarData.getInitial(),
fontSize = (avatarData.size.value / 2).sp,
fontSize = (avatarData.size.dp / 2).value.sp,
color = Color.White,
)
}

View File

@@ -16,17 +16,16 @@
package io.element.android.libraries.designsystem.components.avatar
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
sealed class AvatarSize(open val value: Int) {
sealed class AvatarSize(open val dp: Dp) {
val dp get() = value.dp
object SMALL : AvatarSize(32)
object MEDIUM : AvatarSize(40)
object BIG : AvatarSize(48)
object HUGE : AvatarSize(96)
object SMALL : AvatarSize(32.dp)
object MEDIUM : AvatarSize(40.dp)
object BIG : AvatarSize(48.dp)
object HUGE : AvatarSize(96.dp)
// FIXME maybe remove this field and switch back to an enum (or remove this class) when design system will be integrated
data class Custom(override val value: Int) : AvatarSize(value)
data class Custom(override val dp: Dp) : AvatarSize(dp)
}

View File

@@ -19,8 +19,9 @@ package io.element.android.libraries.matrix.ui.media
import io.element.android.libraries.designsystem.components.avatar.AvatarData
import io.element.android.libraries.matrix.api.media.MediaResolver
import org.matrix.rustcomponents.sdk.mediaSourceFromUrl
import kotlin.math.roundToInt
fun AvatarData.toMetadata(): MediaResolver.Meta {
val mediaSource = url?.let { mediaSourceFromUrl(it) }
return MediaResolver.Meta(source = mediaSource, kind = MediaResolver.Kind.Thumbnail(size.value))
return MediaResolver.Meta(source = mediaSource, kind = MediaResolver.Kind.Thumbnail(size.dp.value.roundToInt()))
}