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>,
|
variants: Vec<Variant>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
|
enum ThemeType {
|
||||||
|
Light,
|
||||||
|
Dark,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
enum Message {
|
enum Message {
|
||||||
ThemeChanged(Theme),
|
ThemeChanged(ThemeType),
|
||||||
ScrollToTop(usize),
|
ScrollToTop(usize),
|
||||||
ScrollToBottom(usize),
|
ScrollToBottom(usize),
|
||||||
Scrolled(usize, f32),
|
Scrolled(usize, f32),
|
||||||
|
|
@ -45,7 +51,10 @@ impl Application for ScrollableDemo {
|
||||||
fn update(&mut self, message: Message) -> Command<Message> {
|
fn update(&mut self, message: Message) -> Command<Message> {
|
||||||
match message {
|
match message {
|
||||||
Message::ThemeChanged(theme) => {
|
Message::ThemeChanged(theme) => {
|
||||||
self.theme = theme;
|
self.theme = match theme {
|
||||||
|
ThemeType::Light => Theme::Light,
|
||||||
|
ThemeType::Dark => Theme::Dark,
|
||||||
|
};
|
||||||
|
|
||||||
Command::none()
|
Command::none()
|
||||||
}
|
}
|
||||||
|
|
@ -79,16 +88,16 @@ impl Application for ScrollableDemo {
|
||||||
|
|
||||||
fn view(&self) -> Element<Message> {
|
fn view(&self) -> Element<Message> {
|
||||||
let ScrollableDemo {
|
let ScrollableDemo {
|
||||||
theme, variants, ..
|
variants, ..
|
||||||
} = self;
|
} = 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!["Choose a theme:"].spacing(10),
|
||||||
|column, option| {
|
|column, option| {
|
||||||
column.push(radio(
|
column.push(radio(
|
||||||
format!("{:?}", option),
|
format!("{:?}", option),
|
||||||
*option,
|
*option,
|
||||||
Some(*theme),
|
Some(*option),
|
||||||
Message::ThemeChanged,
|
Message::ThemeChanged,
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue