diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2021-11-03 16:02:58 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2021-11-03 16:02:58 +0530 |
commit | 2a9d2177a5985a76020a5dc6b9248343d18e26bc (patch) | |
tree | b82910866328cf830df9be034992af2b3bac3ab5 | |
parent | 3fc5f17920dbd6f40d20539487ae34b05d857f73 (diff) |
app: add dynamic colors support to Compose
-rw-r--r-- | app/src/main/java/dev/msfjarvis/aps/ui/theme/Theme.kt | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/theme/Theme.kt b/app/src/main/java/dev/msfjarvis/aps/ui/theme/Theme.kt index 55fb600d..b4f47cb2 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/theme/Theme.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/theme/Theme.kt @@ -1,8 +1,11 @@ package dev.msfjarvis.aps.ui.theme +import android.content.Context import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable @@ -64,12 +67,16 @@ private val DarkThemeColors = ) @Composable -fun APSTheme(useDarkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { +fun APSTheme( + useDynamicColors: Boolean = true, + useDarkTheme: Boolean = isSystemInDarkTheme(), + context: Context, + content: @Composable () -> Unit, +) { val colors = - if (!useDarkTheme) { - LightThemeColors - } else { - DarkThemeColors + when (useDarkTheme) { + true -> if (useDynamicColors) dynamicDarkColorScheme(context) else DarkThemeColors + false -> if (useDynamicColors) dynamicLightColorScheme(context) else LightThemeColors } MaterialTheme(colorScheme = colors, typography = AppTypography, content = content) |