Mikołaj Kąkol10/26/2021, 5:20 AM
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.
maciejciemiega10/26/2021, 7:30 AM
. 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
to it, if you have direct access to
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.
matvei10/26/2021, 9:23 AM
that every clickable/toggleable/checkable widget accepts as a parameter. You can create such state yourself and own it, calling
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.
val pressed = interactionSournce.collectAsPressed()
Mikołaj Kąkol10/26/2021, 1:54 PM
maciejciemiega10/26/2021, 2:47 PM
Mikołaj Kąkol10/26/2021, 5:27 PM
matvei10/27/2021, 5:00 PM
Mikołaj Kąkol10/27/2021, 5:04 PM
matvei10/27/2021, 5:05 PM