@@ -234,14 +234,49 @@ class JetsnackColors(
234234 notificationBadge = other.notificationBadge
235235 isDark = other.isDark
236236 }
237+
238+ fun copy (): JetsnackColors = JetsnackColors (
239+ gradient6_1 = gradient6_1,
240+ gradient6_2 = gradient6_2,
241+ gradient3_1 = gradient3_1,
242+ gradient3_2 = gradient3_2,
243+ gradient2_1 = gradient2_1,
244+ gradient2_2 = gradient2_2,
245+ gradient2_3 = gradient2_3,
246+ brand = brand,
247+ brandSecondary = brandSecondary,
248+ uiBackground = uiBackground,
249+ uiBorder = uiBorder,
250+ uiFloated = uiFloated,
251+ interactivePrimary = interactivePrimary,
252+ interactiveSecondary = interactiveSecondary,
253+ interactiveMask = interactiveMask,
254+ textPrimary = textPrimary,
255+ textSecondary = textSecondary,
256+ textHelp = textHelp,
257+ textInteractive = textInteractive,
258+ textLink = textLink,
259+ tornado1 = tornado1,
260+ iconPrimary = iconPrimary,
261+ iconSecondary = iconSecondary,
262+ iconInteractive = iconInteractive,
263+ iconInteractiveInactive = iconInteractiveInactive,
264+ error = error,
265+ notificationBadge = notificationBadge,
266+ isDark = isDark,
267+ )
237268}
238269
239270@Composable
240271fun ProvideJetsnackColors (
241272 colors : JetsnackColors ,
242273 content : @Composable () -> Unit
243274) {
244- val colorPalette = remember { colors }
275+ val colorPalette = remember {
276+ // Explicitly creating a new object here so we don't mutate the initial [colors]
277+ // provided, and overwrite the values set in it.
278+ colors.copy()
279+ }
245280 colorPalette.update(colors)
246281 CompositionLocalProvider (LocalJetsnackColors provides colorPalette, content = content)
247282}
0 commit comments