Lucas Kivi
06/05/2024, 3:11 AMViewModel
or should colors be determined from within the UI based on more abstract UI substate? (Imagine a color that changes based on whether or not there is an error.)
I am trying to deduce whether our practice of determining colors in the VM layer (we actually have a “transformation” layer that transforms a VM’s internal state to UI state) was poor practice. In the XML view paradigm, we could easily set colors into UI state emitted by the ViewModel
using color resources. However, with compose color themes provided by `CompositionLocalProvider`s, we can’t do such a thing!
The declarative UI ideal is that UI state should describe how the UI should look. It seems the color might need to be a part of that description at times.Kirill Grouchnikov
06/05/2024, 3:20 AMLucas Kivi
06/05/2024, 3:32 PMKirill Grouchnikov
06/05/2024, 5:36 PMLucas Kivi
06/05/2024, 8:41 PMColor
.Mark Murphy
06/05/2024, 10:26 PMColor
. You are trying to determine whether you can use an abstraction first and derive that Color
outside of the viewmodel.
Those two things are not necessarily in conflict. Some higher-order composable (e.g., a design system wrapper) could derive the Color
from the abstraction, and use that Color
with the leaf composable(s) that render the UI.Lucas Kivi
06/06/2024, 12:29 AMColor
from the ViewModel
.