diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs index f0cd60f4d3..d5cf19ccbd 100644 --- a/examples/scrollable/src/main.rs +++ b/examples/scrollable/src/main.rs @@ -207,7 +207,7 @@ impl Application for ScrollableDemo { } fn theme(&self) -> Theme { - self.theme + self.theme.clone() } } diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs index 625a2b9a21..784ea581ae 100644 --- a/examples/styling/src/main.rs +++ b/examples/styling/src/main.rs @@ -53,7 +53,10 @@ impl Sandbox for Styling { }; let extended = Extended::generate(palette); Styling { - custom_theme: Theme::Custom { palette, extended }, + custom_theme: Theme::Custom { + palette: Box::new(palette), + extended: Box::new(extended) + }, ..Default::default() } } @@ -67,7 +70,7 @@ impl Sandbox for Styling { Message::ThemeChanged(theme) => self.theme = match theme { ThemeType::Light => Theme::Light, ThemeType::Dark => Theme::Dark, - ThemeType::Custom => self.custom_theme, + ThemeType::Custom => self.custom_theme.clone(), }, Message::InputChanged(value) => self.input_value = value, Message::ButtonPressed => {} @@ -163,6 +166,6 @@ impl Sandbox for Styling { } fn theme(&self) -> Theme { - self.theme + self.theme.clone() } } diff --git a/style/src/theme.rs b/style/src/theme.rs index cdd04e3e72..6c2246925f 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -21,13 +21,13 @@ use crate::toggler; use iced_core::{Background, Color}; -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, PartialEq)] pub enum Theme { Light, Dark, Custom { - palette: Palette, - extended: Extended + palette: Box, + extended: Box, } } @@ -36,7 +36,7 @@ impl Theme { match self { Self::Light => Palette::LIGHT, Self::Dark => Palette::DARK, - Self::Custom { palette, .. } => palette + Self::Custom { palette, .. } => *palette } } @@ -78,7 +78,7 @@ impl application::StyleSheet for Theme { background_color: palette.background.base.color, text_color: palette.background.base.text, }, - Application::Custom(f) => f(*self), + Application::Custom(f) => f(self.clone()), } } }