Skip to content

Commit

Permalink
Fix typography line height style
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth Agarwal committed May 31, 2024
1 parent 2650b02 commit 2286c89
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.LineHeightStyle
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.sp
import org.hisp.dhis.mobile.ui.designsystem.resource.provideFontResource
Expand Down Expand Up @@ -39,34 +40,39 @@ fun DHIS2Theme(content: @Composable () -> Unit) {
headlineLarge = TextStyle(
fontSize = 32.sp,
lineHeight = 40.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontFamily = provideFontResource("roboto_regular"),
fontWeight = FontWeight.Normal,
color = TextColor.OnSurface,
),
headlineMedium = TextStyle(
fontSize = 28.sp,
lineHeight = 36.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontFamily = provideFontResource("roboto_regular"),
fontWeight = FontWeight.Normal,
color = TextColor.OnSurface,
),
headlineSmall = TextStyle(
fontSize = 24.sp,
lineHeight = 32.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontFamily = provideFontResource("roboto_regular"),
fontWeight = FontWeight.Normal,
color = TextColor.OnSurface,
),
titleLarge = TextStyle(
fontSize = 20.sp,
lineHeight = 28.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontFamily = provideFontResource("roboto_medium"),
fontWeight = FontWeight.Medium,
color = TextColor.OnSurface,
),
titleMedium = TextStyle(
fontSize = 16.sp,
lineHeight = 24.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontFamily = provideFontResource("roboto_medium"),
fontWeight = FontWeight.Medium,
color = TextColor.OnSurface,
Expand All @@ -76,6 +82,7 @@ fun DHIS2Theme(content: @Composable () -> Unit) {
titleSmall = TextStyle(
fontSize = 14.sp,
lineHeight = 20.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontFamily = provideFontResource("roboto_medium"),
fontWeight = FontWeight.Medium,
color = TextColor.OnSurface,
Expand All @@ -84,6 +91,7 @@ fun DHIS2Theme(content: @Composable () -> Unit) {
labelLarge = TextStyle(
fontSize = 14.sp,
lineHeight = 20.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontFamily = provideFontResource("roboto_medium"),
fontWeight = FontWeight.Medium,
color = TextColor.OnSurface,
Expand All @@ -92,6 +100,7 @@ fun DHIS2Theme(content: @Composable () -> Unit) {
labelMedium = TextStyle(
fontSize = 12.sp,
lineHeight = 16.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontFamily = provideFontResource("roboto_medium"),
fontWeight = FontWeight.Medium,
color = TextColor.OnSurface,
Expand All @@ -100,6 +109,7 @@ fun DHIS2Theme(content: @Composable () -> Unit) {
labelSmall = TextStyle(
fontSize = 11.sp,
lineHeight = 16.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontFamily = provideFontResource("roboto_medium"),
fontWeight = FontWeight.Medium,
color = TextColor.OnSurface,
Expand All @@ -108,6 +118,7 @@ fun DHIS2Theme(content: @Composable () -> Unit) {
bodyLarge = TextStyle(
fontSize = 16.sp,
lineHeight = 24.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontFamily = provideFontResource("roboto_regular"),
fontWeight = FontWeight.Normal,
color = TextColor.OnSurface,
Expand All @@ -116,6 +127,7 @@ fun DHIS2Theme(content: @Composable () -> Unit) {
bodyMedium = TextStyle(
fontSize = 14.sp,
lineHeight = 20.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontFamily = provideFontResource("roboto_regular"),
fontWeight = FontWeight.Normal,
color = TextColor.OnSurface,
Expand All @@ -124,6 +136,7 @@ fun DHIS2Theme(content: @Composable () -> Unit) {
bodySmall = TextStyle(
fontSize = 12.sp,
lineHeight = 16.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontFamily = provideFontResource("roboto_regular"),
fontWeight = FontWeight.Normal,
color = TextColor.OnSurface,
Expand Down Expand Up @@ -156,36 +169,47 @@ fun getTextStyle(style: DHIS2TextStyle): TextStyle {
DHIS2TextStyle.HEADLINE_LARGE -> {
MaterialTheme.typography.headlineLarge
}

DHIS2TextStyle.HEADLINE_MEDIUM -> {
MaterialTheme.typography.headlineMedium
}

DHIS2TextStyle.HEADLINE_SMALL -> {
MaterialTheme.typography.headlineSmall
}

DHIS2TextStyle.TITLE_LARGE -> {
MaterialTheme.typography.titleLarge
}

DHIS2TextStyle.TITLE_MEDIUM -> {
MaterialTheme.typography.titleMedium
}

DHIS2TextStyle.TITLE_SMALL -> {
MaterialTheme.typography.titleSmall
}

DHIS2TextStyle.LABEL_LARGE -> {
MaterialTheme.typography.labelLarge
}

DHIS2TextStyle.LABEL_MEDIUM -> {
MaterialTheme.typography.labelMedium
}

DHIS2TextStyle.LABEL_SMALL -> {
MaterialTheme.typography.labelSmall
}

DHIS2TextStyle.BODY_LARGE -> {
MaterialTheme.typography.bodyLarge
}

DHIS2TextStyle.BODY_MEDIUM -> {
MaterialTheme.typography.bodyMedium
}

DHIS2TextStyle.BODY_SMALL -> {
MaterialTheme.typography.bodySmall
}
Expand All @@ -197,6 +221,7 @@ internal object DHIS2SCustomTextStyles {
val titleMediumBold = TextStyle(
fontSize = 16.sp,
lineHeight = 24.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontWeight = FontWeight.Bold,
color = TextColor.OnSurface,
letterSpacing = 0.15.sp,
Expand All @@ -205,6 +230,7 @@ internal object DHIS2SCustomTextStyles {
val bodyLargeBold = TextStyle(
fontSize = 16.sp,
lineHeight = 24.sp,
lineHeightStyle = LineHeightStyles.CentreAlignNoTrim,
fontWeight = FontWeight.Bold,
color = TextColor.OnSurface,
letterSpacing = 0.5.sp,
Expand Down Expand Up @@ -234,3 +260,10 @@ internal object DHIS2SCustomTextStyles {
fontWeight = FontWeight.Normal,
)
}

internal object LineHeightStyles {
val CentreAlignNoTrim = LineHeightStyle(
LineHeightStyle.Alignment.Center,
LineHeightStyle.Trim.None,
)
}

0 comments on commit 2286c89

Please sign in to comment.