Last active
November 1, 2022 07:42
-
-
Save krzdabrowski/f0dd99a0cbb548b42935da17253db46f 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
@Composable | |
fun AndroidStarterTheme( | |
darkTheme: Boolean = isSystemInDarkTheme(), | |
content: @Composable () -> Unit | |
) { | |
val colorScheme = pickColorScheme(darkTheme) | |
(...) | |
MaterialTheme( | |
colorScheme = colorScheme, | |
typography = Typography, | |
content = content | |
) | |
} | |
@Composable | |
fun pickColorScheme( | |
darkTheme: Boolean | |
): ColorScheme = when { | |
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { | |
val context = LocalContext.current | |
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) | |
} | |
darkTheme -> DarkColorScheme | |
else -> LightColorScheme | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment