mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 08:17:04 +05:30
android: force navigation bar color update when system theme changes
This commit is contained in:
parent
2e503422c8
commit
2bfdab7a1a
1 changed files with 4 additions and 1 deletions
|
@ -16,6 +16,7 @@ import androidx.compose.runtime.setValue
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.res.painterResource
|
||||
|
@ -72,6 +73,7 @@ fun LobstersApp(
|
|||
colorScheme = decideColorScheme(LocalContext.current),
|
||||
) {
|
||||
ProvideWindowInsets {
|
||||
val currentUiMode = LocalConfiguration.current.uiMode
|
||||
val systemBarsColor = MaterialTheme.colorScheme.surfaceColorAtNavigationBarElevation()
|
||||
val navItems =
|
||||
listOf(
|
||||
|
@ -89,7 +91,8 @@ fun LobstersApp(
|
|||
|
||||
SideEffect { systemUiController.setStatusBarColor(color = systemBarsColor) }
|
||||
|
||||
LaunchedEffect(currentDestination) {
|
||||
// Track UI mode as a key to force a navbar color update when dark theme is toggled
|
||||
LaunchedEffect(currentDestination, currentUiMode) {
|
||||
val color =
|
||||
if (currentDestination !in navItems.map { it.route }) {
|
||||
Color.Transparent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue