mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-15 09:57:04 +05:30
android: use the correct nav color and make the check fancier
This commit is contained in:
parent
f03a55543e
commit
d15bf23eee
1 changed files with 3 additions and 3 deletions
|
@ -14,7 +14,6 @@ import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.platform.LocalConfiguration
|
import androidx.compose.ui.platform.LocalConfiguration
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
@ -75,6 +74,7 @@ fun LobstersApp(
|
||||||
ProvideWindowInsets {
|
ProvideWindowInsets {
|
||||||
val currentUiMode = LocalConfiguration.current.uiMode
|
val currentUiMode = LocalConfiguration.current.uiMode
|
||||||
val systemBarsColor = MaterialTheme.colorScheme.surfaceColorAtNavigationBarElevation()
|
val systemBarsColor = MaterialTheme.colorScheme.surfaceColorAtNavigationBarElevation()
|
||||||
|
val backgroundColor = MaterialTheme.colorScheme.background
|
||||||
val navItems =
|
val navItems =
|
||||||
listOf(
|
listOf(
|
||||||
NavigationItem(
|
NavigationItem(
|
||||||
|
@ -94,8 +94,8 @@ fun LobstersApp(
|
||||||
// Track UI mode as a key to force a navbar color update when dark theme is toggled
|
// Track UI mode as a key to force a navbar color update when dark theme is toggled
|
||||||
LaunchedEffect(currentDestination, currentUiMode) {
|
LaunchedEffect(currentDestination, currentUiMode) {
|
||||||
val color =
|
val color =
|
||||||
if (currentDestination !in navItems.map { it.route }) {
|
if (navItems.none { item -> item.route == currentDestination }) {
|
||||||
Color.Transparent
|
backgroundColor
|
||||||
} else {
|
} else {
|
||||||
systemBarsColor
|
systemBarsColor
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue