Skip to content

Instantly share code, notes, and snippets.

@tfaki
Created October 24, 2022 10:57
Show Gist options
  • Save tfaki/e3873843a2cef2fef464189776a38cc8 to your computer and use it in GitHub Desktop.
Save tfaki/e3873843a2cef2fef464189776a38cc8 to your computer and use it in GitHub Desktop.
@Composable
fun YourTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
val dynamicColor = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
val colors = if (dynamicColor) {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
} else {
if (darkTheme) DarkColorPalette else LightColorPalette
}
MaterialTheme(
colorScheme = colors,
typography = Typography,
shapes = Shapes,
content = content
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment