Let AvatarType be the receiver of avatarShape()
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user