Skip to content

Commit

Permalink
[Fix] Fix navigation bar color in light theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghai committed Dec 16, 2023
1 parent 14fe93a commit 34c1e34
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

package me.zhanghai.android.untracker.ui.text

import android.app.Activity
import android.os.Build
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -51,6 +54,7 @@ import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -60,9 +64,12 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp
import androidx.core.view.WindowCompat
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.SharingStarted
Expand All @@ -83,6 +90,17 @@ fun TextBottomSheet(
onSetProcessedText: ((String) -> Unit)?,
onDismiss: () -> Unit
) {
val view = LocalView.current
if (!view.isInEditMode) {
val context = LocalContext.current
val darkTheme = isSystemInDarkTheme()
SideEffect {
val window = (context as Activity).window
val insetsController = WindowCompat.getInsetsController(window, view)
insetsController.isAppearanceLightNavigationBars = !darkTheme
}
}

val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
val coroutineScope = rememberCoroutineScope()
val dismiss: () -> Unit = {
Expand Down

0 comments on commit 34c1e34

Please sign in to comment.