Skip to content

Instantly share code, notes, and snippets.

@hsmnzaydn
Last active June 24, 2022 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsmnzaydn/43cdb89eab0d66a1179ab5ea7a056559 to your computer and use it in GitHub Desktop.
Save hsmnzaydn/43cdb89eab0d66a1179ab5ea7a056559 to your computer and use it in GitHub Desktop.
@Composable
fun MaterialTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color android 12 ve üstü için geçerli
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
(view.context as Activity).window.statusBarColor = colorScheme.primary.toArgb()
ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = darkTheme
}
}
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment