Skip to content

Commit e752f1c

Browse files
committed
Use different line-height for wrapped texts
1 parent 2453694 commit e752f1c

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

  • WordPress/src/jetpack/java/org/wordpress/android/ui/accounts/login/components

WordPress/src/jetpack/java/org/wordpress/android/ui/accounts/login/components/LoopingText.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.compose.runtime.Composable
66
import androidx.compose.ui.Modifier
77
import androidx.compose.ui.res.colorResource
88
import androidx.compose.ui.res.stringArrayResource
9+
import androidx.compose.ui.text.ParagraphStyle
910
import androidx.compose.ui.text.SpanStyle
1011
import androidx.compose.ui.text.TextStyle
1112
import androidx.compose.ui.text.buildAnnotatedString
@@ -20,6 +21,7 @@ import org.wordpress.android.ui.compose.theme.AppTheme
2021
import org.wordpress.android.util.extensions.isOdd
2122

2223
private val fontSize = 40.sp
24+
private val lineHeight = fontSize / 100 * 105 // last value = % of fontSize
2325

2426
@Composable
2527
private fun LargeTexts() {
@@ -30,16 +32,15 @@ private fun LargeTexts() {
3032

3133
val styledText = buildAnnotatedString {
3234
texts.forEachIndexed { index, text ->
33-
when ((index + 1).isOdd) {
34-
true -> withStyle(SpanStyle(color = secondaryColor)) {
35-
append(text)
35+
withStyle(ParagraphStyle(lineHeight = lineHeight)) {
36+
when ((index + 1).isOdd) {
37+
true -> withStyle(SpanStyle(color = secondaryColor)) {
38+
append(text)
39+
}
40+
false -> withStyle(SpanStyle(color = primaryColor)) {
41+
append(text)
42+
}
3643
}
37-
false -> withStyle(SpanStyle(color = primaryColor)) {
38-
append(text)
39-
}
40-
}
41-
if (index != texts.lastIndex) {
42-
append("\n")
4344
}
4445
}
4546
}

0 commit comments

Comments
 (0)