I'm trying to create a custom color scheme for Com...
# compose
I'm trying to create a custom color scheme for Compose. According to the official docs it can be done like this:
Copy code
data class CustomColors(
    val content: Color,
    val component: Color,
    val background: List<Color>
Then I'd use a
inside my custom theme to provide these colors. However, looking at different community samples I noticed that they do it like this:
Copy code
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(
    fun updateColorsFrom(other: AppColors) {
        primary = other.primary
        secondary = other.seconday
Basically replicating the
class implementation. My question is which approach should I follow? I understand that by using
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
? Any thoughts on this will be appreciated
If your colour scheme is static and you don't want to animate colours then just having a plain data class is fine. Using mutable state backed properties is only useful if you change some (but not all colours) at runtime.
🙏 1
my thoughts as well, thanks for clearing it out