enhancement: review text style definitions (#825)

This commit is contained in:
Diego Beraldin 2024-05-10 22:10:34 +02:00 committed by GitHub
parent 6686649977
commit 52a76a2daf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 64 additions and 45 deletions

View File

@ -10,6 +10,10 @@ import androidx.compose.ui.unit.sp
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.UiFontFamily
import com.github.diegoberaldin.raccoonforlemmy.core.resources.di.getCoreResources
/*
* Reference:
* https://m3.material.io/styles/typography/type-scale-tokens#40fc37f8-3269-4aa3-9f28-c6113079ac5d
*/
@Composable
fun UiFontFamily.toTypography(): Typography {
val coreResources = remember { getCoreResources() }
@ -23,30 +27,41 @@ fun UiFontFamily.toTypography(): Typography {
// h1
displayLarge = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight.Light,
fontSize = 96.sp,
letterSpacing = (-1.5).sp,
fontWeight = FontWeight.Normal,
fontSize = 57.sp,
letterSpacing = (-.25).sp,
lineHeight = 64.sp,
),
// h2
displayMedium = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight.Light,
fontSize = 60.sp,
letterSpacing = (-0.5).sp,
fontWeight = FontWeight.Normal,
fontSize = 45.sp,
letterSpacing = 0.sp,
lineHeight = 52.sp,
),
// h3
displaySmall = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight.Normal,
fontSize = 38.sp,
fontSize = 36.sp,
letterSpacing = 0.sp,
lineHeight = 44.sp,
),
headlineLarge = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight.Normal,
fontSize = 32.sp,
letterSpacing = 0.sp,
lineHeight = 40.sp,
),
// h4
headlineMedium = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight.Normal,
fontSize = 34.sp,
letterSpacing = (0.25).sp,
fontSize = 28.sp,
letterSpacing = 0.sp,
lineHeight = 36.sp,
),
// h5
headlineSmall = TextStyle(
@ -54,20 +69,23 @@ fun UiFontFamily.toTypography(): Typography {
fontWeight = FontWeight.Normal,
fontSize = 24.sp,
letterSpacing = 0.sp,
lineHeight = 23.sp,
),
// h6
titleLarge = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight.Medium,
fontSize = 16.sp,
letterSpacing = (0.15).sp,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
letterSpacing = 0.sp,
lineHeight = 28.sp,
),
// subtitle1
titleMedium = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight.Normal,
fontWeight = FontWeight.Medium,
fontSize = 16.sp,
letterSpacing = (0.15).sp,
lineHeight = 24.sp,
),
// subtitle2
titleSmall = TextStyle(
@ -75,6 +93,7 @@ fun UiFontFamily.toTypography(): Typography {
fontWeight = FontWeight.Medium,
fontSize = 14.sp,
letterSpacing = (0.1).sp,
lineHeight = 20.sp,
),
// body1
bodyLarge = TextStyle(
@ -82,6 +101,7 @@ fun UiFontFamily.toTypography(): Typography {
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
letterSpacing = (0.5).sp,
lineHeight = 24.sp,
),
// body2
bodyMedium = TextStyle(
@ -89,19 +109,7 @@ fun UiFontFamily.toTypography(): Typography {
fontWeight = FontWeight.Normal,
fontSize = 14.sp,
letterSpacing = (0.25).sp,
),
labelMedium = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight.Normal,
fontSize = 12.sp,
letterSpacing = (0.5).sp,
),
// button
labelLarge = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight.Medium,
fontSize = 14.sp,
letterSpacing = (0.1).sp,
lineHeight = 20.sp,
),
// caption
bodySmall = TextStyle(
@ -109,13 +117,30 @@ fun UiFontFamily.toTypography(): Typography {
fontWeight = FontWeight.Normal,
fontSize = 12.sp,
letterSpacing = (0.4).sp,
lineHeight = 16.sp,
),
// button
labelLarge = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight.Medium,
fontSize = 14.sp,
letterSpacing = (0.1).sp,
lineHeight = 20.sp,
),
labelMedium = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight.Medium,
fontSize = 12.sp,
letterSpacing = (0.5).sp,
lineHeight = 16.sp,
),
// overline
labelSmall = TextStyle(
fontFamily = fontFamily,
fontWeight = FontWeight.Normal,
fontSize = 10.sp,
letterSpacing = (0.5).sp, // original: 1.5
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
letterSpacing = (0.5).sp,
lineHeight = 16.sp,
),
)
}

View File

@ -118,7 +118,7 @@ fun CommunityHeader(
) {
Text(
text = community.readableName(preferNicknames),
style = MaterialTheme.typography.titleLarge,
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onBackground,
)
if (community.readableHandle != community.readableName(preferNicknames)) {

View File

@ -42,7 +42,7 @@ fun SettingsHeader(
Text(
text = title,
color = fullColor,
style = MaterialTheme.typography.titleLarge,
style = MaterialTheme.typography.titleMedium,
)
Spacer(modifier = Modifier.weight(1f))
if (rightButton != null) {

View File

@ -39,7 +39,10 @@ fun SettingsRow(
val ancillaryColor = MaterialTheme.colorScheme.onBackground.copy(alpha = ancillaryTextAlpha)
Row(
modifier = modifier
.padding(vertical = Spacing.s, horizontal = Spacing.m)
.padding(
vertical = Spacing.s,
horizontal = Spacing.m,
)
.onClick(
onClick = {
onTap?.invoke()

View File

@ -117,7 +117,7 @@ fun UserHeader(
) {
Text(
text = user.readableName(preferNicknames),
style = MaterialTheme.typography.titleLarge,
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onBackground,
)
if (user.readableHandle != user.readableName(preferNicknames)) {

View File

@ -182,7 +182,6 @@ internal object ProfileMainScreen : Tab {
Text(
modifier = Modifier.padding(horizontal = Spacing.s),
text = LocalXmlStrings.current.navigationProfile,
style = MaterialTheme.typography.titleLarge,
)
},
actions = {

View File

@ -134,7 +134,6 @@ class SettingsScreen : Screen {
Text(
modifier = Modifier.padding(horizontal = Spacing.s),
text = LocalXmlStrings.current.navigationSettings,
style = MaterialTheme.typography.titleLarge,
)
},
)

View File

@ -122,7 +122,6 @@ class BanUserScreen(
}
Text(
text = title,
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onBackground,
)
},

View File

@ -187,7 +187,6 @@ class CreateCommentScreen(
LocalXmlStrings.current.createCommentTitle
}
},
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onBackground,
)
},

View File

@ -251,7 +251,6 @@ class CreatePostScreen(
editedPost != null -> LocalXmlStrings.current.editPostTitle
else -> LocalXmlStrings.current.createPostTitle
},
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onBackground,
)
},

View File

@ -112,7 +112,6 @@ class CreateReportScreen(
}
Text(
text = title,
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onBackground,
)
},

View File

@ -118,7 +118,6 @@ class LoginBottomSheet : Screen {
title = {
Text(
text = LocalXmlStrings.current.profileButtonLogin,
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onBackground,
)
},

View File

@ -136,7 +136,7 @@ class ManageSubscriptionsScreen : Screen {
Text(
modifier = Modifier.padding(horizontal = Spacing.s),
text = LocalXmlStrings.current.navigationDrawerTitleSubscriptions,
style = MaterialTheme.typography.titleLarge
style = MaterialTheme.typography.titleMedium
)
},
scrollBehavior = scrollBehavior,
@ -263,7 +263,7 @@ class ManageSubscriptionsScreen : Screen {
) {
Text(
text = LocalXmlStrings.current.manageSubscriptionsHeaderMulticommunities,
style = MaterialTheme.typography.titleLarge,
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onBackground,
)
Spacer(modifier = Modifier.weight(1f))
@ -332,7 +332,7 @@ class ManageSubscriptionsScreen : Screen {
) {
Text(
text = LocalXmlStrings.current.manageSubscriptionsHeaderSubscriptions,
style = MaterialTheme.typography.titleLarge,
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onBackground,
)
}

View File

@ -94,7 +94,6 @@ class MultiCommunityEditorScreen(
title = {
Text(
text = LocalXmlStrings.current.multiCommunityEditorTitle,
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onBackground,
)
},

View File

@ -108,7 +108,6 @@ class RemoveScreen(
title = {
Text(
text = LocalXmlStrings.current.modActionRemove,
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onBackground,
)
},