From bce38bb24b9ad214df0ec78a5a0277ea8e155ece Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 12 Sep 2022 19:45:00 +0100 Subject: [PATCH] adding back a light theme or make use of the dynamic colour scheme --- .../app/dapk/st/design/components/Theme.kt | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/design-library/src/main/kotlin/app/dapk/st/design/components/Theme.kt b/design-library/src/main/kotlin/app/dapk/st/design/components/Theme.kt index 45259ba..3d8fd4d 100644 --- a/design-library/src/main/kotlin/app/dapk/st/design/components/Theme.kt +++ b/design-library/src/main/kotlin/app/dapk/st/design/components/Theme.kt @@ -1,8 +1,7 @@ package app.dapk.st.design.components -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.darkColorScheme -import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext @@ -18,13 +17,16 @@ private val DARK_COLOURS = darkColorScheme( onPrimary = Color(0xDDFFFFFF), ) -private val DARK_EXTENDED = createExtended(DARK_COLOURS.primary, DARK_COLOURS.onPrimary) +private val LIGHT_COLOURS = lightColorScheme( + primary = Palette.brandPrimary, + onPrimary = Color(0xDDFFFFFF), +) private fun createExtended(primary: Color, onPrimary: Color) = ExtendedColors( selfBubble = primary, onSelfBubble = onPrimary, othersBubble = Color(0x20EDEDED), - onOthersBubble = DARK_COLOURS.onPrimary, + onOthersBubble = onPrimary, selfBubbleReplyBackground = Color(0x40EAEAEA), otherBubbleReplyBackground = Color(0x20EAEAEA), missingImageColors = listOf( @@ -49,15 +51,23 @@ data class ExtendedColors( } } -private val LocalExtendedColors = staticCompositionLocalOf { DARK_EXTENDED } +private val LocalExtendedColors = staticCompositionLocalOf { throw IllegalAccessError() } @Composable fun SmallTalkTheme(themeConfig: ThemeConfig, content: @Composable () -> Unit) { val systemUiController = rememberSystemUiController() + val systemInDarkTheme = isSystemInDarkTheme() + val colorScheme = if (themeConfig.useDynamicTheme) { - dynamicDarkColorScheme(LocalContext.current) + when (systemInDarkTheme) { + true -> dynamicDarkColorScheme(LocalContext.current) + false -> dynamicLightColorScheme(LocalContext.current) + } } else { - DARK_COLOURS + when (systemInDarkTheme) { + true -> DARK_COLOURS + false -> LIGHT_COLOURS + } } MaterialTheme(colorScheme = colorScheme) { val backgroundColor = MaterialTheme.colorScheme.background