diff options
author | 2024-01-10 08:15:05 +0100 | |
---|---|---|
committer | 2024-01-10 10:01:51 +0100 | |
commit | 3850a46db6e13f2948f5731f4ceec42764391f5d (patch) | |
tree | 032c2cf31412cbc87beef56b7654bbc1a1909c81 /examples/layout | |
parent | d76705df29f1960124bd06277683448e18f788b0 (diff) | |
download | iced-3850a46db6e13f2948f5731f4ceec42764391f5d.tar.gz iced-3850a46db6e13f2948f5731f4ceec42764391f5d.tar.bz2 iced-3850a46db6e13f2948f5731f4ceec42764391f5d.zip |
Add `Theme` selector to `layout` example
Diffstat (limited to 'examples/layout')
-rw-r--r-- | examples/layout/src/main.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/examples/layout/src/main.rs b/examples/layout/src/main.rs index e23b2218..c1ff3951 100644 --- a/examples/layout/src/main.rs +++ b/examples/layout/src/main.rs @@ -1,8 +1,8 @@ use iced::executor; use iced::keyboard; use iced::widget::{ - button, checkbox, column, container, horizontal_space, row, text, - vertical_rule, + button, checkbox, column, container, horizontal_space, pick_list, row, + text, vertical_rule, }; use iced::{ color, Alignment, Application, Color, Command, Element, Font, Length, @@ -17,13 +17,15 @@ pub fn main() -> iced::Result { struct Layout { example: Example, explain: bool, + theme: Theme, } -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone)] enum Message { Next, Previous, ExplainToggled(bool), + ThemeSelected(Theme), } impl Application for Layout { @@ -37,6 +39,7 @@ impl Application for Layout { Self { example: Example::default(), explain: false, + theme: Theme::Light, }, Command::none(), ) @@ -57,6 +60,9 @@ impl Application for Layout { Message::ExplainToggled(explain) => { self.explain = explain; } + Message::ThemeSelected(theme) => { + self.theme = theme; + } } Command::none() @@ -75,7 +81,13 @@ impl Application for Layout { text(self.example.title).size(20).font(Font::MONOSPACE), horizontal_space(Length::Fill), checkbox("Explain", self.explain, Message::ExplainToggled), + pick_list( + Theme::ALL, + Some(self.theme.clone()), + Message::ThemeSelected + ), ] + .spacing(20) .align_items(Alignment::Center); let example = container(if self.explain { @@ -115,7 +127,7 @@ impl Application for Layout { } fn theme(&self) -> Theme { - Theme::Dark + self.theme.clone() } } |