https://kotlinlang.org logo
#compose
Title
# compose
k

Kirill Grouchnikov

12/03/2020, 11:08 PM
Is there something in core Compose or maybe the material layer that "propagates" the enabled state to the content / children composables? Specifically, I'm looking at the
Button
composable that uses
enabled
to configure the surface and content color. Is
AmbientContentColor
then used at the icon level to tint the child icon in the disabled state? What if the icon is not created from one of the material icons, but rather a "simple" bitmap? What would be the recommended way to propagate the disabled state to it so that it can draw itself at, say, 50% alpha?
l

Louis Pullen-Freilich [G]

12/03/2020, 11:30 PM
You 'own' the enabled state, in that you explicitly pass it to the
Button
, so if you want to do something custom like that you should just explicitly pass it through to the
Button
and the bitmap inside - content color doesn't respresent states, but just the preferred content color inside a component at a given point in time
a

allan.conda

12/04/2020, 4:15 AM
Do you want to apply it as a general rule to your app? You should probably defining it in your theme
or you can check how Material implements it.
Copy code
disabledContentColor: Color = MaterialTheme.colors.onSurface
            .copy(alpha = ContentAlpha.disabled)
3 Views