diff options
Diffstat (limited to 'ui')
| -rw-r--r-- | ui/compose/build.gradle.kts | 3 | ||||
| -rw-r--r-- | ui/compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt | 19 |
2 files changed, 18 insertions, 4 deletions
diff --git a/ui/compose/build.gradle.kts b/ui/compose/build.gradle.kts index 81d1e4cd..10fb9065 100644 --- a/ui/compose/build.gradle.kts +++ b/ui/compose/build.gradle.kts @@ -21,6 +21,7 @@ dependencies { api(libs.compose.material3) api(libs.compose.ui.core) implementation(libs.androidx.core.ktx) - implementation(libs.compose.ui.tooling) + implementation(libs.compose.ui.tooling.preview) + debugImplementation(libs.compose.ui.tooling) testImplementation(libs.bundles.testDependencies) } diff --git a/ui/compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt b/ui/compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt index 6d762fb4..957bf543 100644 --- a/ui/compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt +++ b/ui/compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt @@ -6,7 +6,8 @@ package app.passwordstore.ui.compose.theme import android.app.Activity -import android.os.Build +import android.graphics.Color as AndroidColor +import android.view.Window import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme @@ -15,6 +16,7 @@ import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable import androidx.compose.runtime.SideEffect +import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalView import androidx.core.view.WindowCompat @@ -84,7 +86,7 @@ public fun APSTheme( ) { val colorScheme = when { - dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + dynamicColor -> { val context = LocalContext.current if (darkTheme) { dynamicDarkColorScheme(context) @@ -98,8 +100,19 @@ public fun APSTheme( if (!view.isInEditMode) { SideEffect { val window = (view.context as Activity).window - WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme + val bars = WindowCompat.getInsetsController(window, view) + bars.isAppearanceLightStatusBars = !darkTheme + bars.isAppearanceLightNavigationBars = !darkTheme + paintBars(window, colorScheme.background.toArgb()) } } MaterialTheme(colorScheme = colorScheme, typography = AppTypography, content = content) } + +/** Colors the system bars, except in windows that keep them see-through (autofill decryption). */ +@Suppress("DEPRECATION") // Deprecated with edge-to-edge, which targetSdk 34 does not force. +private fun paintBars(window: Window, color: Int) { + if (window.statusBarColor == AndroidColor.TRANSPARENT) return + window.statusBarColor = color + window.navigationBarColor = color +} |
