Let AvatarType be the receiver of avatarShape()

This commit is contained in:
Benoit Marty
2025-06-23 18:34:52 +02:00
parent 0f6dd82b97
commit 688fbdd1bd
4 changed files with 6 additions and 8 deletions

View File

@@ -13,11 +13,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Shape
@Composable
fun avatarShape(
avatarType: AvatarType,
): Shape {
return when (avatarType) {
is AvatarType.Space -> RoundedCornerShape(avatarType.cornerSize)
fun AvatarType.avatarShape(): Shape {
return when (this) {
is AvatarType.Space -> RoundedCornerShape(cornerSize)
is AvatarType.Room,
AvatarType.User -> CircleShape
}

View File

@@ -36,7 +36,7 @@ internal fun ImageAvatar(
contentScale = ContentScale.Companion.Crop,
modifier = modifier
.size(size)
.clip(avatarShape(avatarType))
.clip(avatarType.avatarShape())
) {
val collectedState by painter.state.collectAsState()
when (val state = collectedState) {

View File

@@ -42,7 +42,7 @@ internal fun TextAvatar(
Box(
modifier
.size(size)
.clip(avatarShape(avatarType))
.clip(avatarType.avatarShape())
.background(color = colors.background)
) {
val fontSize = size.toSp() / 2

View File

@@ -48,7 +48,7 @@ fun UnsavedAvatar(
) {
val commonModifier = modifier
.size(70.dp)
.clip(avatarShape(avatarType))
.clip(avatarType.avatarShape())
if (avatarUri != null) {
val context = LocalContext.current