Jorge Domínguez
07/08/2022, 4:31 PM@Immutable
data class CustomColors(
val content: Color,
val component: Color,
val background: List<Color>
)
Then I'd use a CompositionLocal
inside my custom theme to provide these colors. However, looking at different community samples I noticed that they do it like this:
class AppColors(
primary: Color,
secondary: Color
)
var primary by mutableStateOf(primary)
private set
var secondary by mutableStateOf(secondary)
private set
fun copy(
primary: Color = this.primary,
secondary: Color = this.secondary
): AppColors = AppColors(
primary,
secondary
)
fun updateColorsFrom(other: AppColors) {
primary = other.primary
secondary = other.seconday
}
}
Basically replicating the MaterialTheme
Colors
class implementation. My question is which approach should I follow? I understand that by using mutableStateOf()
I can guarantee that Composables will react to individual color updates, but what if I know that my color scheme will never change at runtime? Is that the only reason to use mutableStateOf()
? Any thoughts on this will be appreciatedLouis Pullen-Freilich [G]
07/08/2022, 4:33 PMJorge Domínguez
07/08/2022, 4:40 PM