This commit is contained in:
parent
d5a933b047
commit
4f3215f48e
3 changed files with 12 additions and 9 deletions
|
|
@ -207,7 +207,7 @@ impl Application for ScrollableDemo {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn theme(&self) -> Theme {
|
fn theme(&self) -> Theme {
|
||||||
self.theme
|
self.theme.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,10 @@ impl Sandbox for Styling {
|
||||||
};
|
};
|
||||||
let extended = Extended::generate(palette);
|
let extended = Extended::generate(palette);
|
||||||
Styling {
|
Styling {
|
||||||
custom_theme: Theme::Custom { palette, extended },
|
custom_theme: Theme::Custom {
|
||||||
|
palette: Box::new(palette),
|
||||||
|
extended: Box::new(extended)
|
||||||
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -67,7 +70,7 @@ impl Sandbox for Styling {
|
||||||
Message::ThemeChanged(theme) => self.theme = match theme {
|
Message::ThemeChanged(theme) => self.theme = match theme {
|
||||||
ThemeType::Light => Theme::Light,
|
ThemeType::Light => Theme::Light,
|
||||||
ThemeType::Dark => Theme::Dark,
|
ThemeType::Dark => Theme::Dark,
|
||||||
ThemeType::Custom => self.custom_theme,
|
ThemeType::Custom => self.custom_theme.clone(),
|
||||||
},
|
},
|
||||||
Message::InputChanged(value) => self.input_value = value,
|
Message::InputChanged(value) => self.input_value = value,
|
||||||
Message::ButtonPressed => {}
|
Message::ButtonPressed => {}
|
||||||
|
|
@ -163,6 +166,6 @@ impl Sandbox for Styling {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn theme(&self) -> Theme {
|
fn theme(&self) -> Theme {
|
||||||
self.theme
|
self.theme.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@ 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 {
|
||||||
palette: Palette,
|
palette: Box<Palette>,
|
||||||
extended: Extended
|
extended: Box<Extended>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ impl Theme {
|
||||||
match self {
|
match self {
|
||||||
Self::Light => Palette::LIGHT,
|
Self::Light => Palette::LIGHT,
|
||||||
Self::Dark => Palette::DARK,
|
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,
|
background_color: palette.background.base.color,
|
||||||
text_color: palette.background.base.text,
|
text_color: palette.background.base.text,
|
||||||
},
|
},
|
||||||
Application::Custom(f) => f(*self),
|
Application::Custom(f) => f(self.clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue