aboutsummaryrefslogtreecommitdiffstats
path: root/ui-compose/src/main/kotlin/app/passwordstore/ui/compose
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2022-07-23 19:15:36 +0530
committerGitHub <noreply@github.com>2022-07-23 13:45:36 +0000
commit9c5e9c8e4381aaa2886d0ad03070b2a57a937cce (patch)
tree5c1d13d4879c6efe7082b8a987d34aec38a64e10 /ui-compose/src/main/kotlin/app/passwordstore/ui/compose
parent6d0bff144c35c9f2c73f34065e972b3f48a34241 (diff)
downloadHardenedPass-9c5e9c8e4381aaa2886d0ad03070b2a57a937cce.tar.gz
HardenedPass-9c5e9c8e4381aaa2886d0ad03070b2a57a937cce.zip
Improvements to key list activity (#2030)
Diffstat (limited to 'ui-compose/src/main/kotlin/app/passwordstore/ui/compose')
-rw-r--r--ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/Theme.kt15
-rw-r--r--ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/utils.kt27
2 files changed, 31 insertions, 11 deletions
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 9bd8003e..695ff6cc 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
@@ -1,12 +1,12 @@
package app.passwordstore.ui.compose.theme
-import androidx.compose.foundation.isSystemInDarkTheme
+import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
-private val LightThemeColors =
+internal val LightThemeColors =
lightColorScheme(
primary = md_theme_light_primary,
onPrimary = md_theme_light_onPrimary,
@@ -34,7 +34,7 @@ private val LightThemeColors =
inverseOnSurface = md_theme_light_inverseOnSurface,
inverseSurface = md_theme_light_inverseSurface,
)
-private val DarkThemeColors =
+internal val DarkThemeColors =
darkColorScheme(
primary = md_theme_dark_primary,
onPrimary = md_theme_dark_onPrimary,
@@ -65,15 +65,8 @@ private val DarkThemeColors =
@Composable
public fun APSTheme(
- useDarkTheme: Boolean = isSystemInDarkTheme(),
+ colors: ColorScheme,
content: @Composable () -> Unit,
) {
- val colors =
- if (!useDarkTheme) {
- LightThemeColors
- } else {
- DarkThemeColors
- }
-
MaterialTheme(colorScheme = colors, typography = AppTypography, content = content)
}
diff --git a/ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/utils.kt b/ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/utils.kt
new file mode 100644
index 00000000..096862dc
--- /dev/null
+++ b/ui-compose/src/main/kotlin/app/passwordstore/ui/compose/theme/utils.kt
@@ -0,0 +1,27 @@
+package app.passwordstore.ui.compose.theme
+
+import android.content.Context
+import android.os.Build
+import androidx.compose.foundation.isSystemInDarkTheme
+import androidx.compose.material3.ColorScheme
+import androidx.compose.material3.dynamicDarkColorScheme
+import androidx.compose.material3.dynamicLightColorScheme
+import androidx.compose.runtime.Composable
+
+@Composable
+public fun decideColorScheme(context: Context): ColorScheme {
+ val isDarkTheme = isSystemInDarkTheme()
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
+ if (isDarkTheme) {
+ dynamicDarkColorScheme(context)
+ } else {
+ dynamicLightColorScheme(context)
+ }
+ } else {
+ if (isDarkTheme) {
+ DarkThemeColors
+ } else {
+ LightThemeColors
+ }
+ }
+}