Box Custom in Theme

This commit is contained in:
Héctor Ramón Jiménez 2022-11-03 03:27:55 +01:00
parent f04336dd5c
commit df78777675
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
3 changed files with 6 additions and 6 deletions

View file

@ -205,7 +205,7 @@ impl Application for ScrollableDemo {
} }
fn theme(&self) -> Theme { fn theme(&self) -> Theme {
self.theme self.theme.clone()
} }
} }

View file

@ -159,6 +159,6 @@ impl Sandbox for Styling {
} }
fn theme(&self) -> Theme { fn theme(&self) -> Theme {
self.theme self.theme.clone()
} }
} }

View file

@ -21,19 +21,19 @@ use crate::toggler;
use iced_core::{Background, Color}; use iced_core::{Background, Color};
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub enum Theme { pub enum Theme {
Light, Light,
Dark, Dark,
Custom(Custom), Custom(Box<Custom>),
} }
impl Theme { impl Theme {
pub fn custom(palette: Palette) -> Self { pub fn custom(palette: Palette) -> Self {
Self::Custom(Custom::new(palette)) Self::Custom(Box::new(Custom::new(palette)))
} }
pub fn palette(self) -> Palette { pub fn palette(&self) -> Palette {
match self { match self {
Self::Light => Palette::LIGHT, Self::Light => Palette::LIGHT,
Self::Dark => Palette::DARK, Self::Dark => Palette::DARK,