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
val window = (view.context as Activity).window
if (!view.isInEditMode) {
SideEffect {
WindowCompat.setDecorFitsSystemWindows(window, false)
window.navigationBarColor = Color.Transparent.toArgb()
WindowInsetsControllerCompat(window, view).let {
it.isAppearanceLightStatusBars = !darkTheme
}
}
}
MaterialTheme(
colorScheme = colorScheme,
typography = ...,
content = ...
)
标签:Compose,状态栏,val,colorScheme,Jetpack,window,context,darkTheme,view
From: https://www.cnblogs.com/thisDart/p/16726042.html