Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Sep 11, 2022
1 parent c0ee1d1 commit 68647fc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/scrollable/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl Application for ScrollableDemo {
}

fn theme(&self) -> Theme {
self.theme
self.theme.clone()
}
}

Expand Down
9 changes: 6 additions & 3 deletions examples/styling/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand All @@ -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 => {}
Expand Down Expand Up @@ -163,6 +166,6 @@ impl Sandbox for Styling {
}

fn theme(&self) -> Theme {
self.theme
self.theme.clone()
}
}
10 changes: 5 additions & 5 deletions style/src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Palette>,
extended: Box<Extended>,
}
}

Expand All @@ -36,7 +36,7 @@ impl Theme {
match self {
Self::Light => Palette::LIGHT,
Self::Dark => Palette::DARK,
Self::Custom { palette, .. } => palette
Self::Custom { palette, .. } => *palette
}
}

Expand Down Expand Up @@ -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()),
}
}
}
Expand Down

0 comments on commit 68647fc

Please sign in to comment.