Colton Idle
04/21/2021, 8:10 PMColton Idle
04/21/2021, 8:10 PMButton(onClick = {}, enabled = false) {
Text("Button is: Disabled")
Icon(
imageVector = Icons.Filled.AccountBox,
contentDescription = null,
tint = MaterialTheme.colors.onPrimary,
)
}
Chris Sinco [G]
04/21/2021, 8:22 PMIcon
which is likely overriding the CompositionLocalProvider
settings on all content in the ButtonChris Sinco [G]
04/21/2021, 8:23 PMcontentColor
is used for the children of Button in their respective color parameters.Chris Sinco [G]
04/21/2021, 8:24 PMJavier
04/21/2021, 8:28 PMColton Idle
04/21/2021, 8:34 PMChris Sinco [G]
04/21/2021, 8:34 PMChris Sinco [G]
04/21/2021, 8:35 PMColton Idle
04/21/2021, 8:37 PMChris Sinco [G]
04/21/2021, 8:40 PMcontentColor
. Maybe @Adam Powell can verifyAdam Powell
04/21/2021, 8:45 PMLouis Pullen-Freilich [G]
04/21/2021, 8:46 PMAdam Powell
04/21/2021, 8:47 PMLouis Pullen-Freilich [G]
04/21/2021, 8:48 PMColton Idle
04/21/2021, 9:20 PMLouis Pullen-Freilich [G]
04/21/2021, 9:26 PM// enabled captured in scope
Button(enabled = enabled, ...) {
val tint = if (enabled) MaterialTheme.colors.primary else LocalContentColor.current
val color = tint.copy(alpha = LocalContentAlpha.current)
}
(You can ignore the alpha if you always want the image to be opaque)
There doesn’t need to be any magic here, Button
just suggests what the content should be, but if you want it to be different in different states, you already own that state 🙂