How to change statusbar and navigation bar color in JetpackCompose App?

PressRex profile image
by PressRex
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

PressRex profile image
by PressRex

Subscribe to New Posts

Lorem ultrices malesuada sapien amet pulvinar quis. Feugiat etiam ullamcorper pharetra vitae nibh enim vel.

Success! Now Check Your Email

To complete Subscribe, click the confirmation link in your inbox. If it doesn’t arrive within 3 minutes, check your spam folder.

Ok, Thanks

Read More