diff --git a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt index b54a5f3c73..75558ecc7a 100644 --- a/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt +++ b/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Theme.kt @@ -21,11 +21,7 @@ import androidx.compose.material.Colors import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.runtime.Stable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue +import androidx.compose.runtime.Immutable import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.graphics.Color @@ -107,169 +103,44 @@ object JetsnackTheme { /** * Jetsnack custom Color Palette */ -@Stable -class JetsnackColors( - gradient6_1: List, - gradient6_2: List, - gradient3_1: List, - gradient3_2: List, - gradient2_1: List, - gradient2_2: List, - gradient2_3: List, - brand: Color, - brandSecondary: Color, - uiBackground: Color, - uiBorder: Color, - uiFloated: Color, - interactivePrimary: List = gradient2_1, - interactiveSecondary: List = gradient2_2, - interactiveMask: List = gradient6_1, - textPrimary: Color = brand, - textSecondary: Color, - textHelp: Color, - textInteractive: Color, - textLink: Color, - tornado1: List, - iconPrimary: Color = brand, - iconSecondary: Color, - iconInteractive: Color, - iconInteractiveInactive: Color, - error: Color, - notificationBadge: Color = error, - isDark: Boolean -) { - var gradient6_1 by mutableStateOf(gradient6_1) - private set - var gradient6_2 by mutableStateOf(gradient6_2) - private set - var gradient3_1 by mutableStateOf(gradient3_1) - private set - var gradient3_2 by mutableStateOf(gradient3_2) - private set - var gradient2_1 by mutableStateOf(gradient2_1) - private set - var gradient2_2 by mutableStateOf(gradient2_2) - private set - var gradient2_3 by mutableStateOf(gradient2_3) - private set - var brand by mutableStateOf(brand) - private set - var brandSecondary by mutableStateOf(brandSecondary) - private set - var uiBackground by mutableStateOf(uiBackground) - private set - var uiBorder by mutableStateOf(uiBorder) - private set - var uiFloated by mutableStateOf(uiFloated) - private set - var interactivePrimary by mutableStateOf(interactivePrimary) - private set - var interactiveSecondary by mutableStateOf(interactiveSecondary) - private set - var interactiveMask by mutableStateOf(interactiveMask) - private set - var textPrimary by mutableStateOf(textPrimary) - private set - var textSecondary by mutableStateOf(textSecondary) - private set - var textHelp by mutableStateOf(textHelp) - private set - var textInteractive by mutableStateOf(textInteractive) - private set - var tornado1 by mutableStateOf(tornado1) - private set - var textLink by mutableStateOf(textLink) - private set - var iconPrimary by mutableStateOf(iconPrimary) - private set - var iconSecondary by mutableStateOf(iconSecondary) - private set - var iconInteractive by mutableStateOf(iconInteractive) - private set - var iconInteractiveInactive by mutableStateOf(iconInteractiveInactive) - private set - var error by mutableStateOf(error) - private set - var notificationBadge by mutableStateOf(notificationBadge) - private set - var isDark by mutableStateOf(isDark) - private set - - fun update(other: JetsnackColors) { - gradient6_1 = other.gradient6_1 - gradient6_2 = other.gradient6_2 - gradient3_1 = other.gradient3_1 - gradient3_2 = other.gradient3_2 - gradient2_1 = other.gradient2_1 - gradient2_2 = other.gradient2_2 - gradient2_3 = other.gradient2_3 - brand = other.brand - brandSecondary = other.brandSecondary - uiBackground = other.uiBackground - uiBorder = other.uiBorder - uiFloated = other.uiFloated - interactivePrimary = other.interactivePrimary - interactiveSecondary = other.interactiveSecondary - interactiveMask = other.interactiveMask - textPrimary = other.textPrimary - textSecondary = other.textSecondary - textHelp = other.textHelp - textInteractive = other.textInteractive - textLink = other.textLink - tornado1 = other.tornado1 - iconPrimary = other.iconPrimary - iconSecondary = other.iconSecondary - iconInteractive = other.iconInteractive - iconInteractiveInactive = other.iconInteractiveInactive - error = other.error - notificationBadge = other.notificationBadge - isDark = other.isDark - } - - fun copy(): JetsnackColors = JetsnackColors( - gradient6_1 = gradient6_1, - gradient6_2 = gradient6_2, - gradient3_1 = gradient3_1, - gradient3_2 = gradient3_2, - gradient2_1 = gradient2_1, - gradient2_2 = gradient2_2, - gradient2_3 = gradient2_3, - brand = brand, - brandSecondary = brandSecondary, - uiBackground = uiBackground, - uiBorder = uiBorder, - uiFloated = uiFloated, - interactivePrimary = interactivePrimary, - interactiveSecondary = interactiveSecondary, - interactiveMask = interactiveMask, - textPrimary = textPrimary, - textSecondary = textSecondary, - textHelp = textHelp, - textInteractive = textInteractive, - textLink = textLink, - tornado1 = tornado1, - iconPrimary = iconPrimary, - iconSecondary = iconSecondary, - iconInteractive = iconInteractive, - iconInteractiveInactive = iconInteractiveInactive, - error = error, - notificationBadge = notificationBadge, - isDark = isDark, - ) -} +@Immutable +data class JetsnackColors( + val gradient6_1: List, + val gradient6_2: List, + val gradient3_1: List, + val gradient3_2: List, + val gradient2_1: List, + val gradient2_2: List, + val gradient2_3: List, + val brand: Color, + val brandSecondary: Color, + val uiBackground: Color, + val uiBorder: Color, + val uiFloated: Color, + val interactivePrimary: List = gradient2_1, + val interactiveSecondary: List = gradient2_2, + val interactiveMask: List = gradient6_1, + val textPrimary: Color = brand, + val textSecondary: Color, + val textHelp: Color, + val textInteractive: Color, + val textLink: Color, + val tornado1: List, + val iconPrimary: Color = brand, + val iconSecondary: Color, + val iconInteractive: Color, + val iconInteractiveInactive: Color, + val error: Color, + val notificationBadge: Color = error, + val isDark: Boolean +) @Composable fun ProvideJetsnackColors( colors: JetsnackColors, content: @Composable () -> Unit ) { - val colorPalette = remember { - // Explicitly creating a new object here so we don't mutate the initial [colors] - // provided, and overwrite the values set in it. - colors.copy() - } - colorPalette.update(colors) - CompositionLocalProvider(LocalJetsnackColors provides colorPalette, content = content) + CompositionLocalProvider(LocalJetsnackColors provides colors, content = content) } private val LocalJetsnackColors = staticCompositionLocalOf {