Last active
June 24, 2022 19:49
-
-
Save hsmnzaydn/43cdb89eab0d66a1179ab5ea7a056559 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 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