How to change statusbar and navigation bar color in JetpackCompose App?
I want to change status bar and navigation bar color in my app by default it is not set. This is my composeable AppTheme
function which I need to apply the change in.
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = colorScheme.primary.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
}
}
private val DarkColorScheme = darkColorScheme(
primaryContainer = Color.Black,
onPrimaryContainer = Color.White
)
private val LightColorScheme = lightColorScheme(
primary = RoyalBlue,
primaryContainer = RoyalBlue,
onPrimaryContainer = Color.White
)
Source: View source