-
-
Save damianpetla/d3c2a8215807d3a1c4463820ece34272 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// somwhere in the theming code | |
data class MyTypography( | |
val bigText: TextStyle = TextStyle( | |
fontFamily = FontFamily.Monospace, | |
fontSize = 16.sp, | |
fontWeight = FontWeight.Bold | |
), | |
val smallText: TextStyle = TextStyle( | |
fontFamily = FontFamily.Monospace, | |
fontSize = 16.sp, | |
fontWeight = FontWeight.Bold | |
) | |
) | |
val LocalSimpleTypography = staticCompositionLocalOf { MyTypography() } | |
object CustomTheme { | |
val dimensions | |
@Composable | |
@ReadOnlyComposable | |
get() = LocalDimensions.current | |
val typography | |
@Composable | |
@ReadOnlyComposable | |
get() = LocalSimpleTypography.current | |
} | |
// somewhere at the top level of your UI hierarchy | |
CompositionLocalProvider( | |
LocalDimensions provides Dimensions(), | |
LocalSimpleTypography provides MyTypography() | |
) { | |
MaterialTheme( | |
colors = colors, | |
shapes = Shapes, | |
content = content | |
) | |
} | |
// somewhere in the layouts | |
Text( | |
text = "Hello", | |
style = CustomTheme.typography.bigText | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment