fix: scrollable example
This commit is contained in:
parent
bc26dff2ca
commit
269d6f9a3f
1 changed files with 14 additions and 5 deletions
|
|
@ -14,9 +14,15 @@ struct ScrollableDemo {
|
|||
variants: Vec<Variant>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
enum ThemeType {
|
||||
Light,
|
||||
Dark,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
enum Message {
|
||||
ThemeChanged(Theme),
|
||||
ThemeChanged(ThemeType),
|
||||
ScrollToTop(usize),
|
||||
ScrollToBottom(usize),
|
||||
Scrolled(usize, f32),
|
||||
|
|
@ -45,7 +51,10 @@ impl Application for ScrollableDemo {
|
|||
fn update(&mut self, message: Message) -> Command<Message> {
|
||||
match message {
|
||||
Message::ThemeChanged(theme) => {
|
||||
self.theme = theme;
|
||||
self.theme = match theme {
|
||||
ThemeType::Light => Theme::Light,
|
||||
ThemeType::Dark => Theme::Dark,
|
||||
};
|
||||
|
||||
Command::none()
|
||||
}
|
||||
|
|
@ -79,16 +88,16 @@ impl Application for ScrollableDemo {
|
|||
|
||||
fn view(&self) -> Element<Message> {
|
||||
let ScrollableDemo {
|
||||
theme, variants, ..
|
||||
variants, ..
|
||||
} = self;
|
||||
|
||||
let choose_theme = [Theme::Light, Theme::Dark].iter().fold(
|
||||
let choose_theme = [ThemeType::Light, ThemeType::Dark].iter().fold(
|
||||
column!["Choose a theme:"].spacing(10),
|
||||
|column, option| {
|
||||
column.push(radio(
|
||||
format!("{:?}", option),
|
||||
*option,
|
||||
Some(*theme),
|
||||
Some(*option),
|
||||
Message::ThemeChanged,
|
||||
))
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue