@@ -21,11 +21,7 @@ import androidx.compose.material.Colors
2121import androidx.compose.material.MaterialTheme
2222import androidx.compose.runtime.Composable
2323import androidx.compose.runtime.CompositionLocalProvider
24- import androidx.compose.runtime.Stable
25- import androidx.compose.runtime.getValue
26- import androidx.compose.runtime.mutableStateOf
27- import androidx.compose.runtime.remember
28- import androidx.compose.runtime.setValue
24+ import androidx.compose.runtime.Immutable
2925import androidx.compose.runtime.staticCompositionLocalOf
3026import androidx.compose.ui.graphics.Color
3127
@@ -107,169 +103,44 @@ object JetsnackTheme {
107103/* *
108104 * Jetsnack custom Color Palette
109105 */
110- @Stable
111- class JetsnackColors (
112- gradient6_1 : List <Color >,
113- gradient6_2 : List <Color >,
114- gradient3_1 : List <Color >,
115- gradient3_2 : List <Color >,
116- gradient2_1 : List <Color >,
117- gradient2_2 : List <Color >,
118- gradient2_3 : List <Color >,
119- brand : Color ,
120- brandSecondary : Color ,
121- uiBackground : Color ,
122- uiBorder : Color ,
123- uiFloated : Color ,
124- interactivePrimary : List <Color > = gradient2_1,
125- interactiveSecondary : List <Color > = gradient2_2,
126- interactiveMask : List <Color > = gradient6_1,
127- textPrimary : Color = brand,
128- textSecondary : Color ,
129- textHelp : Color ,
130- textInteractive : Color ,
131- textLink : Color ,
132- tornado1 : List <Color >,
133- iconPrimary : Color = brand,
134- iconSecondary : Color ,
135- iconInteractive : Color ,
136- iconInteractiveInactive : Color ,
137- error : Color ,
138- notificationBadge : Color = error,
139- isDark : Boolean
140- ) {
141- var gradient6_1 by mutableStateOf(gradient6_1)
142- private set
143- var gradient6_2 by mutableStateOf(gradient6_2)
144- private set
145- var gradient3_1 by mutableStateOf(gradient3_1)
146- private set
147- var gradient3_2 by mutableStateOf(gradient3_2)
148- private set
149- var gradient2_1 by mutableStateOf(gradient2_1)
150- private set
151- var gradient2_2 by mutableStateOf(gradient2_2)
152- private set
153- var gradient2_3 by mutableStateOf(gradient2_3)
154- private set
155- var brand by mutableStateOf(brand)
156- private set
157- var brandSecondary by mutableStateOf(brandSecondary)
158- private set
159- var uiBackground by mutableStateOf(uiBackground)
160- private set
161- var uiBorder by mutableStateOf(uiBorder)
162- private set
163- var uiFloated by mutableStateOf(uiFloated)
164- private set
165- var interactivePrimary by mutableStateOf(interactivePrimary)
166- private set
167- var interactiveSecondary by mutableStateOf(interactiveSecondary)
168- private set
169- var interactiveMask by mutableStateOf(interactiveMask)
170- private set
171- var textPrimary by mutableStateOf(textPrimary)
172- private set
173- var textSecondary by mutableStateOf(textSecondary)
174- private set
175- var textHelp by mutableStateOf(textHelp)
176- private set
177- var textInteractive by mutableStateOf(textInteractive)
178- private set
179- var tornado1 by mutableStateOf(tornado1)
180- private set
181- var textLink by mutableStateOf(textLink)
182- private set
183- var iconPrimary by mutableStateOf(iconPrimary)
184- private set
185- var iconSecondary by mutableStateOf(iconSecondary)
186- private set
187- var iconInteractive by mutableStateOf(iconInteractive)
188- private set
189- var iconInteractiveInactive by mutableStateOf(iconInteractiveInactive)
190- private set
191- var error by mutableStateOf(error)
192- private set
193- var notificationBadge by mutableStateOf(notificationBadge)
194- private set
195- var isDark by mutableStateOf(isDark)
196- private set
197-
198- fun update (other : JetsnackColors ) {
199- gradient6_1 = other.gradient6_1
200- gradient6_2 = other.gradient6_2
201- gradient3_1 = other.gradient3_1
202- gradient3_2 = other.gradient3_2
203- gradient2_1 = other.gradient2_1
204- gradient2_2 = other.gradient2_2
205- gradient2_3 = other.gradient2_3
206- brand = other.brand
207- brandSecondary = other.brandSecondary
208- uiBackground = other.uiBackground
209- uiBorder = other.uiBorder
210- uiFloated = other.uiFloated
211- interactivePrimary = other.interactivePrimary
212- interactiveSecondary = other.interactiveSecondary
213- interactiveMask = other.interactiveMask
214- textPrimary = other.textPrimary
215- textSecondary = other.textSecondary
216- textHelp = other.textHelp
217- textInteractive = other.textInteractive
218- textLink = other.textLink
219- tornado1 = other.tornado1
220- iconPrimary = other.iconPrimary
221- iconSecondary = other.iconSecondary
222- iconInteractive = other.iconInteractive
223- iconInteractiveInactive = other.iconInteractiveInactive
224- error = other.error
225- notificationBadge = other.notificationBadge
226- isDark = other.isDark
227- }
228-
229- fun copy (): JetsnackColors = JetsnackColors (
230- gradient6_1 = gradient6_1,
231- gradient6_2 = gradient6_2,
232- gradient3_1 = gradient3_1,
233- gradient3_2 = gradient3_2,
234- gradient2_1 = gradient2_1,
235- gradient2_2 = gradient2_2,
236- gradient2_3 = gradient2_3,
237- brand = brand,
238- brandSecondary = brandSecondary,
239- uiBackground = uiBackground,
240- uiBorder = uiBorder,
241- uiFloated = uiFloated,
242- interactivePrimary = interactivePrimary,
243- interactiveSecondary = interactiveSecondary,
244- interactiveMask = interactiveMask,
245- textPrimary = textPrimary,
246- textSecondary = textSecondary,
247- textHelp = textHelp,
248- textInteractive = textInteractive,
249- textLink = textLink,
250- tornado1 = tornado1,
251- iconPrimary = iconPrimary,
252- iconSecondary = iconSecondary,
253- iconInteractive = iconInteractive,
254- iconInteractiveInactive = iconInteractiveInactive,
255- error = error,
256- notificationBadge = notificationBadge,
257- isDark = isDark,
258- )
259- }
106+ @Immutable
107+ data class JetsnackColors (
108+ val gradient6_1 : List <Color >,
109+ val gradient6_2 : List <Color >,
110+ val gradient3_1 : List <Color >,
111+ val gradient3_2 : List <Color >,
112+ val gradient2_1 : List <Color >,
113+ val gradient2_2 : List <Color >,
114+ val gradient2_3 : List <Color >,
115+ val brand : Color ,
116+ val brandSecondary : Color ,
117+ val uiBackground : Color ,
118+ val uiBorder : Color ,
119+ val uiFloated : Color ,
120+ val interactivePrimary : List <Color > = gradient2_1,
121+ val interactiveSecondary : List <Color > = gradient2_2,
122+ val interactiveMask : List <Color > = gradient6_1,
123+ val textPrimary : Color = brand,
124+ val textSecondary : Color ,
125+ val textHelp : Color ,
126+ val textInteractive : Color ,
127+ val textLink : Color ,
128+ val tornado1 : List <Color >,
129+ val iconPrimary : Color = brand,
130+ val iconSecondary : Color ,
131+ val iconInteractive : Color ,
132+ val iconInteractiveInactive : Color ,
133+ val error : Color ,
134+ val notificationBadge : Color = error,
135+ val isDark : Boolean
136+ )
260137
261138@Composable
262139fun ProvideJetsnackColors (
263140 colors : JetsnackColors ,
264141 content : @Composable () -> Unit
265142) {
266- val colorPalette = remember {
267- // Explicitly creating a new object here so we don't mutate the initial [colors]
268- // provided, and overwrite the values set in it.
269- colors.copy()
270- }
271- colorPalette.update(colors)
272- CompositionLocalProvider (LocalJetsnackColors provides colorPalette, content = content)
143+ CompositionLocalProvider (LocalJetsnackColors provides colors, content = content)
273144}
274145
275146private val LocalJetsnackColors = staticCompositionLocalOf<JetsnackColors > {
0 commit comments