Created
November 12, 2024 14:02
-
-
Save JakubNeukirch/be291eddb4b7a25e9b640429eb6d93b1 to your computer and use it in GitHub Desktop.
Style in Kotlin Multiplatform Compose
This file contains hidden or 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
// LocalAppTheme | |
val LocalAppTheme = staticCompositionLocalOf { DefaultAppTheme } | |
val DefaultAppTheme = AppTheme( | |
colors = DarkThemeColors, | |
typography = DefaultAppTypography, | |
dimension = DefaultAppDimension | |
) | |
// AppTheme | |
data class AppTheme( | |
val colors: AppColors, | |
val typography: AppTypography, | |
val dimension: AppDimension, | |
) | |
@Composable | |
fun AppTheme(content: @Composable () -> Unit) { | |
CompositionLocalProvider( | |
LocalAppTheme provides DarkAppTheme(), | |
) { | |
val appTheme = LocalAppTheme.current | |
changeSystemBarsColor( | |
statusBarColor = appTheme.colors.greyscale.c100, | |
navBarColor = appTheme.colors.greyscale.c100, | |
) | |
MaterialTheme( | |
colors = MaterialTheme.colors.copy( | |
primary = appTheme.colors.primary.c60,//specify some colors in default material theme as well to provide values for default components. | |
background = appTheme.colors.greyscale.c100, | |
onBackground = appTheme.colors.greyscale.c10, | |
), | |
) { | |
content() | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment