Set avatar size value to dp
This commit is contained in:
parent
91deab3b97
commit
d04aae9475
4 changed files with 11 additions and 11 deletions
|
|
@ -222,7 +222,7 @@ fun CreateRoomSearchResultItem(
|
||||||
MatrixUserRow(
|
MatrixUserRow(
|
||||||
modifier = modifier.heightIn(min = 56.dp),
|
modifier = modifier.heightIn(min = 56.dp),
|
||||||
matrixUser = matrixUser,
|
matrixUser = matrixUser,
|
||||||
avatarSize = AvatarSize.Custom(36),
|
avatarSize = AvatarSize.Custom(36.dp),
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ private fun InitialsAvatar(
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.align(Alignment.Center),
|
modifier = Modifier.align(Alignment.Center),
|
||||||
text = avatarData.getInitial(),
|
text = avatarData.getInitial(),
|
||||||
fontSize = (avatarData.size.value / 2).sp,
|
fontSize = (avatarData.size.dp / 2).value.sp,
|
||||||
color = Color.White,
|
color = Color.White,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,17 +16,16 @@
|
||||||
|
|
||||||
package io.element.android.libraries.designsystem.components.avatar
|
package io.element.android.libraries.designsystem.components.avatar
|
||||||
|
|
||||||
|
import androidx.compose.ui.unit.Dp
|
||||||
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.dp)
|
||||||
|
object MEDIUM : AvatarSize(40.dp)
|
||||||
object SMALL : AvatarSize(32)
|
object BIG : AvatarSize(48.dp)
|
||||||
object MEDIUM : AvatarSize(40)
|
object HUGE : AvatarSize(96.dp)
|
||||||
object BIG : AvatarSize(48)
|
|
||||||
object HUGE : AvatarSize(96)
|
|
||||||
|
|
||||||
// FIXME maybe remove this field and switch back to an enum (or remove this class) when design system will be integrated
|
// 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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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.designsystem.components.avatar.AvatarData
|
||||||
import io.element.android.libraries.matrix.api.media.MediaResolver
|
import io.element.android.libraries.matrix.api.media.MediaResolver
|
||||||
import org.matrix.rustcomponents.sdk.mediaSourceFromUrl
|
import org.matrix.rustcomponents.sdk.mediaSourceFromUrl
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
fun AvatarData.toMetadata(): MediaResolver.Meta {
|
fun AvatarData.toMetadata(): MediaResolver.Meta {
|
||||||
val mediaSource = url?.let { mediaSourceFromUrl(it) }
|
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()))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue