Skip to content

Commit

Permalink
Set status and navigation bar colors
Browse files Browse the repository at this point in the history
  • Loading branch information
pipe01 committed Jun 5, 2023
1 parent 44ed7f3 commit da46b9c
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions app/src/main/java/com/jerboa/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.unit.sp
Expand Down Expand Up @@ -75,14 +75,22 @@ fun JerboaTheme(

val view = LocalView.current

if (isSystemInDarkTheme()) {
SideEffect {
val window = (view.context as Activity).window
val insets = WindowCompat.getInsetsController(window, view)
insets.isAppearanceLightStatusBars = false
}
val window = (view.context as Activity).window
val insets = WindowCompat.getInsetsController(window, view)

val isLight = when (themeMode) {
ThemeMode.Black, ThemeMode.Dark -> false
ThemeMode.System, ThemeMode.SystemBlack -> !isSystemInDarkTheme()
else -> true
}

window.statusBarColor = colors.background.toArgb()
// The navigation bar color is also set on BottomAppBarAll
window.navigationBarColor = colors.background.toArgb()

insets.isAppearanceLightStatusBars = isLight
insets.isAppearanceLightNavigationBars = isLight

MaterialTheme(
colorScheme = colors,
typography = typography,
Expand Down

0 comments on commit da46b9c

Please sign in to comment.