Skip to content

Commit

Permalink
Set navbar color depending on whether the bottom app bar is visible
Browse files Browse the repository at this point in the history
  • Loading branch information
pipe01 committed Jun 6, 2023
1 parent da46b9c commit 79bc0ce
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/src/main/java/com/jerboa/ui/components/common/AppBars.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,13 +19,15 @@ 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
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
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 79bc0ce

Please sign in to comment.