Mikołaj Kąkol
10/26/2021, 5:20 AMCompositionLocalPressed/Enabled
would be a good idea?
My main problem is how to change font color based on those states and I’m bit lazy to pass it to each function.maciejciemiega
10/26/2021, 7:30 AMCheckbox
with CheckboxColors
.
Text already reacts LocalContentColor and LocalContentAlpha so you can use these two to control the text based on all your defined states. Or just pass different color
or style
to it, if you have direct access to Text
call.
Of course all this color calculation based on state can be done once e.g. by creating your custom Text composable if that would make you easier for you.matvei
10/26/2021, 9:23 AMInteractionSource
that every clickable/toggleable/checkable widget accepts as a parameter. You can create such state yourself and own it, calling val pressed = interactionSournce.collectAsPressed()
to know whether item is pressed/hovered/focused.
As for enabled and checked, you need to manually lift the state up to the point from where every component that needs to know about such states has access to it.
I would personally avoid creating composition locals to such cases. It created a level of indirection and implicit dependency that could end up complicating logic and making your components less reusable.Mikołaj Kąkol
10/26/2021, 1:54 PMmaciejciemiega
10/26/2021, 2:47 PMMikołaj Kąkol
10/26/2021, 5:27 PMmatvei
10/27/2021, 5:00 PMMikołaj Kąkol
10/27/2021, 5:04 PMmatvei
10/27/2021, 5:05 PM