I think there is a bug in `contentColorFor()`, whe...
# compose
k
I think there is a bug in
contentColorFor()
, when there are two same background colors in a color scheme, it will always return the first content color in both even if we use the second color. I use
contentColorFor(MaterialTheme.colorScheme.surface)
but it gives me
onBackground
.
IMG_20230429_204732_377.jpg
s
If
background
and
surface
are the exact same color, wouldn’t it make sense that
onBackground
and
onSurface
are also the same color?
k
No, in my design system, onBackground has less contrast than onSurface in dark theme.
Like the new text contrast feature in Android 14, they may be different.
s
That's interesting yeah, I guess it's not that weird of a thing. I'd file a feature request on the issue tracker and link it back here, to see what folks from Google think about this too.
r
Considering how this API works I don't see how it could give you the color you want when multiple colors are equal values.
k
Well, so do you consider replacing it with other API? I have to add
contentColor
for all
Surface
.
Or I can add a small value to every channel of
background
.