Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes mostly systembars colors not matching with application #1651

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -128,7 +128,7 @@ fun BottomAppBarAll(
val colorScheme = MaterialTheme.colorScheme

DisposableEffect(Unit) {
window.navigationBarColor = colorScheme.surfaceColorAtElevation(3.dp).toArgb()
window.navigationBarColor = colorScheme.surfaceContainer.toArgb()

onDispose {
window.navigationBarColor = colorScheme.background.toArgb()
16 changes: 16 additions & 0 deletions app/src/main/java/com/jerboa/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -13,9 +13,11 @@ import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.core.graphics.ColorUtils
import androidx.core.view.WindowCompat
import com.jerboa.ThemeColor
import com.jerboa.ThemeMode
import com.jerboa.db.entity.AppSettings
@@ -107,12 +109,26 @@ fun JerboaTheme(

val view = LocalView.current
val window = (view.context as Activity).window
val insets = WindowCompat.getInsetsController(window, view)

val isLight =
when (themeMode) {
ThemeMode.Black, ThemeMode.Dark -> false
ThemeMode.System, ThemeMode.SystemBlack -> !isSystemInDarkTheme()
else -> true
}

if (appSettings.secureWindow) {
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
} else {
window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
}

// The navigation bar color is set on BottomAppBarAll
insets.isAppearanceLightStatusBars = isLight
insets.isAppearanceLightNavigationBars = isLight
window.statusBarColor = Color.Transparent.toArgb()

// Set up a provider to allow access to the custom color scheme from any child element
CompositionLocalProvider(LocalColorScheme provides colors) {
// Set up the default MaterialTheme provider