From 05711cc084a56e4473ab56a7460c460dfdc5a84d Mon Sep 17 00:00:00 2001 From: Felipe Martinez Date: Tue, 6 Jun 2023 02:40:55 +0200 Subject: [PATCH] Set navbar color depending on whether the bottom app bar is visible --- .../com/jerboa/ui/components/common/AppBars.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/main/java/com/jerboa/ui/components/common/AppBars.kt b/app/src/main/java/com/jerboa/ui/components/common/AppBars.kt index 898d6960c..f707ffc8c 100644 --- a/app/src/main/java/com/jerboa/ui/components/common/AppBars.kt +++ b/app/src/main/java/com/jerboa/ui/components/common/AppBars.kt @@ -1,6 +1,7 @@ package com.jerboa.ui.components.common import android.annotation.SuppressLint +import android.app.Activity import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.core.tween import androidx.compose.foundation.ExperimentalFoundationApi @@ -18,6 +19,7 @@ import androidx.compose.material.icons.filled.Person import androidx.compose.material.icons.outlined.* import androidx.compose.material3.* import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -25,6 +27,7 @@ import androidx.compose.ui.draw.drawWithContent import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.TextStyle @@ -85,6 +88,17 @@ fun BottomAppBarAll( val totalUnreads = unreadCounts?.let { unreadCountTotal(it) } if (showBottomNav == true) { + val window = (LocalContext.current as Activity).window + val colorScheme = MaterialTheme.colorScheme + + DisposableEffect(Unit) { + window.navigationBarColor = colorScheme.surfaceColorAtElevation(3.dp).toArgb() + + onDispose { + window.navigationBarColor = colorScheme.background.toArgb() + } + } + BottomAppBar { NavigationBarItem( icon = {