From 395f93ca89c18b2e2f77430f0e2614f53399f7f5 Mon Sep 17 00:00:00 2001 From: fabian Date: Fri, 20 Jan 2023 07:39:24 +0100 Subject: [PATCH] Enable materialYou theme usage. --- .../main/java/me/zobrist/tichucounter/ui/Theme.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/me/zobrist/tichucounter/ui/Theme.kt b/app/src/main/java/me/zobrist/tichucounter/ui/Theme.kt index 4ad4683..1e1e98e 100644 --- a/app/src/main/java/me/zobrist/tichucounter/ui/Theme.kt +++ b/app/src/main/java/me/zobrist/tichucounter/ui/Theme.kt @@ -78,11 +78,16 @@ fun AppTheme( useDarkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit ) { - val colors = if (!useDarkTheme) { - LightColors - } else { - DarkColors - } + + val dynamicColor = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S + + val colors = when { + dynamicColor && useDarkTheme - > dynamicDarkColorScheme(LocalContext.current) + dynamicColor && !useDarkTheme - > dynamicLightColorScheme(LocalContext.current) + darkTheme - > DarkColors + else - > LightColors + } + MaterialTheme( colorScheme = colors,