adding back a light theme or make use of the dynamic colour scheme
This commit is contained in:
parent
ee3d41a741
commit
c6431add42
|
@ -1,8 +1,7 @@
|
||||||
package app.dapk.st.design.components
|
package app.dapk.st.design.components
|
||||||
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.material3.darkColorScheme
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.material3.dynamicDarkColorScheme
|
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
@ -18,13 +17,16 @@ private val DARK_COLOURS = darkColorScheme(
|
||||||
onPrimary = Color(0xDDFFFFFF),
|
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(
|
private fun createExtended(primary: Color, onPrimary: Color) = ExtendedColors(
|
||||||
selfBubble = primary,
|
selfBubble = primary,
|
||||||
onSelfBubble = onPrimary,
|
onSelfBubble = onPrimary,
|
||||||
othersBubble = Color(0x20EDEDED),
|
othersBubble = Color(0x20EDEDED),
|
||||||
onOthersBubble = DARK_COLOURS.onPrimary,
|
onOthersBubble = onPrimary,
|
||||||
selfBubbleReplyBackground = Color(0x40EAEAEA),
|
selfBubbleReplyBackground = Color(0x40EAEAEA),
|
||||||
otherBubbleReplyBackground = Color(0x20EAEAEA),
|
otherBubbleReplyBackground = Color(0x20EAEAEA),
|
||||||
missingImageColors = listOf(
|
missingImageColors = listOf(
|
||||||
|
@ -49,15 +51,23 @@ data class ExtendedColors(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val LocalExtendedColors = staticCompositionLocalOf { DARK_EXTENDED }
|
private val LocalExtendedColors = staticCompositionLocalOf<ExtendedColors> { throw IllegalAccessError() }
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SmallTalkTheme(themeConfig: ThemeConfig, content: @Composable () -> Unit) {
|
fun SmallTalkTheme(themeConfig: ThemeConfig, content: @Composable () -> Unit) {
|
||||||
val systemUiController = rememberSystemUiController()
|
val systemUiController = rememberSystemUiController()
|
||||||
|
val systemInDarkTheme = isSystemInDarkTheme()
|
||||||
|
|
||||||
val colorScheme = if (themeConfig.useDynamicTheme) {
|
val colorScheme = if (themeConfig.useDynamicTheme) {
|
||||||
dynamicDarkColorScheme(LocalContext.current)
|
when (systemInDarkTheme) {
|
||||||
|
true -> dynamicDarkColorScheme(LocalContext.current)
|
||||||
|
false -> dynamicLightColorScheme(LocalContext.current)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DARK_COLOURS
|
when (systemInDarkTheme) {
|
||||||
|
true -> DARK_COLOURS
|
||||||
|
false -> LIGHT_COLOURS
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MaterialTheme(colorScheme = colorScheme) {
|
MaterialTheme(colorScheme = colorScheme) {
|
||||||
val backgroundColor = MaterialTheme.colorScheme.background
|
val backgroundColor = MaterialTheme.colorScheme.background
|
||||||
|
|
Loading…
Reference in New Issue