Use winit to obtain current theme::Mode

This commit is contained in:
Héctor Ramón Jiménez 2025-09-08 05:16:20 +02:00
parent 5c7ae8a3d6
commit 0111f514a1
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
25 changed files with 208 additions and 602 deletions

View file

@ -19,11 +19,11 @@ pub fn main() -> iced::Result {
.run()
}
#[derive(Default, Debug)]
#[derive(Debug, Default)]
struct Layout {
example: Example,
explain: bool,
theme: Theme,
theme: Option<Theme>,
}
#[derive(Debug, Clone)]
@ -51,7 +51,7 @@ impl Layout {
self.explain = explain;
}
Message::ThemeSelected(theme) => {
self.theme = theme;
self.theme = Some(theme);
}
}
}
@ -74,7 +74,8 @@ impl Layout {
horizontal_space(),
checkbox("Explain", self.explain)
.on_toggle(Message::ExplainToggled),
pick_list(Theme::ALL, Some(&self.theme), Message::ThemeSelected),
pick_list(Theme::ALL, self.theme.as_ref(), Message::ThemeSelected)
.placeholder("Theme"),
]
.spacing(20)
.align_y(Center);
@ -116,7 +117,7 @@ impl Layout {
.into()
}
fn theme(&self) -> Theme {
fn theme(&self) -> Option<Theme> {
self.theme.clone()
}
}