Improve rendering of "All chats" regarding fontScale. (#984)

This commit is contained in:
Benoit Marty
2023-07-27 15:42:47 +02:00
committed by Benoit Marty
parent fb870a0903
commit 96b7923979
2 changed files with 15 additions and 1 deletions

View File

@@ -43,6 +43,8 @@ import io.element.android.libraries.designsystem.components.avatar.Avatar
import io.element.android.libraries.designsystem.components.avatar.AvatarSize
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
import io.element.android.libraries.designsystem.text.scaleMax
import io.element.android.libraries.designsystem.text.toSp
import io.element.android.libraries.designsystem.theme.aliasScreenTitle
import io.element.android.libraries.designsystem.theme.components.DropdownMenu
import io.element.android.libraries.designsystem.theme.components.DropdownMenuItem
@@ -114,7 +116,11 @@ private fun DefaultRoomListTopBar(
val fontStyle = if (scrollBehavior.state.collapsedFraction > 0.5)
ElementTheme.typography.aliasScreenTitle
else
ElementTheme.typography.fontHeadingLgBold
ElementTheme.typography.fontHeadingLgBold.copy(
// Due to a limitation of MediumTopAppBar, and to avoid the text to be truncated,
// limit the size to 28.dp instead of 28.sp
fontSize = 28.dp.scaleMax().toSp()
)
Text(
style = fontStyle,
text = stringResource(id = R.string.screen_roomlist_main_space_title)

View File

@@ -52,3 +52,11 @@ fun Dp.toPx(): Float = with(LocalDensity.current) { toPx() }
*/
@Composable
fun Dp.roundToPx(): Int = with(LocalDensity.current) { roundToPx() }
/**
* Return the maximum value between the receiver value and the value with fonScale applied.
*/
@Composable
fun Dp.scaleMax(): Dp = with(LocalDensity.current) {
return this@scaleMax * fontScale.coerceAtMost(1f)
}