From 072f939791df6dea0ff2fcefb12415aa02b610bd Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 7 Feb 2022 11:37:29 +0530 Subject: [PATCH] android: ensure system bar color blending applies to comments screen as well --- .../msfjarvis/claw/android/ui/LobstersApp.kt | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/LobstersApp.kt b/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/LobstersApp.kt index 47f048d7..ac590d42 100644 --- a/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/LobstersApp.kt +++ b/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/LobstersApp.kt @@ -5,6 +5,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.SideEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue @@ -12,6 +13,7 @@ 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.LocalContext import androidx.compose.ui.platform.LocalUriHandler @@ -69,12 +71,6 @@ fun LobstersApp( ) { ProvideWindowInsets { val systemBarsColor = MaterialTheme.colorScheme.surfaceColorAtNavigationBarElevation() - - SideEffect { - systemUiController.setStatusBarColor(color = systemBarsColor) - systemUiController.setNavigationBarColor(color = systemBarsColor) - } - val navItems = listOf( NavigationItem( @@ -89,6 +85,18 @@ fun LobstersApp( ), ) + SideEffect { systemUiController.setStatusBarColor(color = systemBarsColor) } + + LaunchedEffect(currentDestination) { + val color = + if (currentDestination !in navItems.map { it.route }) { + Color.Transparent + } else { + systemBarsColor + } + systemUiController.setNavigationBarColor(color = color) + } + Scaffold( topBar = { ClawAppBar(