SchildiChat / schildichat-android-next

Matrix client / Element X fork
https://schildi.chat/android/next/
GNU Affero General Public License v3.0
86 stars 8 forks source link

Adding Dynamic Colors Material 3 Material You Theme #21

Open hanthor opened 4 months ago

hanthor commented 4 months ago
SpiritCroc commented 4 months ago

Nice, you found ScPrefs :+1:

One of the most important aspects for SchildiChat these days is keeping code easily maintainable in a long term, while avoiding upstream merge conflicts as much as possible. So your changes to ColorAliases.kt would in the current state be a blocker.

More precisely, I could imagine it something like this (untested code, may need some modifications): Your code:

val SemanticColors.pinDigitBg
    get() = if (isLight) {
    @Composable
    get() = if (DynamicColorPreferences.isDynamicColorEnabled) {
        colorScheme.onPrimaryContainer
    } else if (isLight) {
        Color(0xFFF0F2F5)
    } else {
        Color(0xFF26282D)

gets into

val SemanticColors.pinDigitBg
    get() = scSemColorOverride(colorScheme.onPrimaryContainer) ?: if (isLight) {
        // We want LightDesignTokens.colorGray300
        Color(0xFFF0F2F5)
    } else {
        // We want DarkDesignTokens.colorGray400
        Color(0xFF26282D)
    }

where only scSemColorOverride(colorScheme.onPrimaryContainer) ?: was inserted, rest is still upstream, with

@Composable
fun scSemColorOverride(dynamicThemeColor: Color) = dynamicThemeColor.takeIf { DynamicColorPreferences.isDynamicColorEnabled }

in an SC-owned file.

wrenix commented 4 hours ago

Wow, cool PR.

I hope you will add later (lets release this fast) the pureblack option. Is it possible to take that option from the Distro? (LineageOS, CalyxOS and so on).