android: use the correct nav color and make the check fancier

This commit is contained in:
Harsh Shandilya 2022-02-08 02:01:26 +05:30
parent f03a55543e
commit d15bf23eee
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80

View file

@ -14,7 +14,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
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
@ -75,6 +74,7 @@ fun LobstersApp(
ProvideWindowInsets {
val currentUiMode = LocalConfiguration.current.uiMode
val systemBarsColor = MaterialTheme.colorScheme.surfaceColorAtNavigationBarElevation()
val backgroundColor = MaterialTheme.colorScheme.background
val navItems =
listOf(
NavigationItem(
@ -94,8 +94,8 @@ fun LobstersApp(
// 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
if (navItems.none { item -> item.route == currentDestination }) {
backgroundColor
} else {
systemBarsColor
}