Why is _`dynamicDarkColorScheme`_ background and s...
# compose
z
Why is
dynamicDarkColorScheme
background and surface always identical? Has it always been like this?
Surface colors define contained areas, distinguishing them from a background and other on-screen elements.
This makes me feel like its a bug?
This is problematic because
surfaceColorAtElevation
tweaks the surface color based on elevation, but can no longer distinguish it from the background color!
s
Doesn’t elevation does something like take the existing background color + mix it with the
surfaceTint
color instead? https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:tv/tv-ma[…]/material3/ColorScheme.kt;l=507-514?q=surfaceColorAtElevation The background + surface being the same shouldn’t affect this afaik. With that said, those two being 100% identical does sound odd, I don’t think that’s considered normal 🤔
z
Exactly! But that logic is only invoked if the color is surface. Or at least thats what I think its intention is?
Copy code
internal fun ColorScheme.applyTonalElevation(backgroundColor: Color, elevation: Dp): Color {
    return if (backgroundColor == surface) {
        surfaceColorAtElevation(elevation)
    } else {
        backgroundColor
    }
}
s
Yeah it does look like it judging from this code. A question here, this equality there checks for the color value and not the reference right? This means that if surface == background, then the tonal elevation will also apply on background, which isn’t really the intention of that function as I read it 😅
z
Thats exactly my problem 😄
Fwiw, I guess this is a bug? The only other logical reasoning I can get to is that surfaces should never use background as their color, but then again - here I am doing just that!
s
If you file one I’ll +1, I am also curious. I just generated a color scheme from https://m3.material.io/theme-builder#/custom and it did indeed generate the same color for background/surface for dark mode
z
I dont have time to report it right this instant, but Ill leave a linkt to the issue here when I can! 💪🏽
👌 3
Not a day too late! Heres the issue 💪🏽 I added two problems that Ive ran into thus far. Feel free to add a comment if anything more comes to mind! A star is always welcome, and Ive heard that by starring this issue, the world will potentially become a more colorful place. https://issuetracker.google.com/issues/295536724
🌟 1
dynamicLightColorScheme
and
dynamicDarkColorScheme
now return higher chroma colors for surface and
surfaceContainer
roles. (I5e901) 👀
🥳 1