Loading core/ui/compose/designsystem/src/main/kotlin/app/k9mail/core/ui/compose/designsystem/atom/text/TextDisplayMedium.kt +40 −0 Original line number Diff line number Diff line package app.k9mail.core.ui.compose.designsystem.atom.text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.draw.drawWithContent import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.style.TextAlign import app.k9mail.core.ui.compose.theme2.MainTheme import androidx.compose.material3.Text as Material3Text Loading Loading @@ -39,3 +45,37 @@ fun TextDisplayMedium( style = MainTheme.typography.displayMedium, ) } @Composable fun TextDisplayMediumAutoResize( text: String, modifier: Modifier = Modifier, color: Color = Color.Unspecified, textAlign: TextAlign? = null, ) { val style: TextStyle = MainTheme.typography.displayMedium var shouldDraw by remember { mutableStateOf(false) } var resizedTextStyle by remember { mutableStateOf(style) } Material3Text( text = text, modifier = modifier.drawWithContent { if (shouldDraw) { drawContent() } }, color = color, textAlign = textAlign, softWrap = false, style = resizedTextStyle, onTextLayout = { result -> if (result.didOverflowWidth) { resizedTextStyle = resizedTextStyle.copy( fontSize = resizedTextStyle.fontSize * 0.95, ) } else { shouldDraw = true } }, ) } feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/AppTitleTopHeader.kt +2 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import app.k9mail.core.ui.compose.designsystem.atom.text.TextDisplayMedium import app.k9mail.core.ui.compose.designsystem.atom.text.TextDisplayMediumAutoResize import app.k9mail.core.ui.compose.designsystem.template.ResponsiveWidthContainer import app.k9mail.core.ui.compose.theme2.MainTheme Loading Loading @@ -51,7 +51,7 @@ fun AppTitleTopHeader( contentDescription = null, ) TextDisplayMedium(text = title) TextDisplayMediumAutoResize(text = title) } } } Loading
core/ui/compose/designsystem/src/main/kotlin/app/k9mail/core/ui/compose/designsystem/atom/text/TextDisplayMedium.kt +40 −0 Original line number Diff line number Diff line package app.k9mail.core.ui.compose.designsystem.atom.text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.draw.drawWithContent import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.style.TextAlign import app.k9mail.core.ui.compose.theme2.MainTheme import androidx.compose.material3.Text as Material3Text Loading Loading @@ -39,3 +45,37 @@ fun TextDisplayMedium( style = MainTheme.typography.displayMedium, ) } @Composable fun TextDisplayMediumAutoResize( text: String, modifier: Modifier = Modifier, color: Color = Color.Unspecified, textAlign: TextAlign? = null, ) { val style: TextStyle = MainTheme.typography.displayMedium var shouldDraw by remember { mutableStateOf(false) } var resizedTextStyle by remember { mutableStateOf(style) } Material3Text( text = text, modifier = modifier.drawWithContent { if (shouldDraw) { drawContent() } }, color = color, textAlign = textAlign, softWrap = false, style = resizedTextStyle, onTextLayout = { result -> if (result.didOverflowWidth) { resizedTextStyle = resizedTextStyle.copy( fontSize = resizedTextStyle.fontSize * 0.95, ) } else { shouldDraw = true } }, ) }
feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/AppTitleTopHeader.kt +2 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import app.k9mail.core.ui.compose.designsystem.atom.text.TextDisplayMedium import app.k9mail.core.ui.compose.designsystem.atom.text.TextDisplayMediumAutoResize import app.k9mail.core.ui.compose.designsystem.template.ResponsiveWidthContainer import app.k9mail.core.ui.compose.theme2.MainTheme Loading Loading @@ -51,7 +51,7 @@ fun AppTitleTopHeader( contentDescription = null, ) TextDisplayMedium(text = title) TextDisplayMediumAutoResize(text = title) } } }