Use Sandbox in tour example

This commit is contained in:
Héctor Ramón Jiménez 2020-05-28 22:50:40 +02:00
parent 7f9813d4b3
commit 6de0a2c371

View File

@ -1,8 +1,7 @@
use iced::{
button, executor, scrollable, slider, text_input, Application, Button,
Checkbox, Color, Column, Command, Container, Element, HorizontalAlignment,
Image, Length, Radio, Row, Scrollable, Settings, Slider, Space, Text,
TextInput,
button, scrollable, slider, text_input, Button, Checkbox, Color, Column,
Container, Element, HorizontalAlignment, Image, Length, Radio, Row,
Sandbox, Scrollable, Settings, Slider, Space, Text, TextInput,
};
pub fn main() {
@ -19,29 +18,24 @@ pub struct Tour {
debug: bool,
}
impl Application for Tour {
type Executor = executor::Null;
impl Sandbox for Tour {
type Message = Message;
type Flags = ();
fn new(_flags: ()) -> (Tour, Command<Message>) {
(
fn new() -> Tour {
Tour {
steps: Steps::new(),
scroll: scrollable::State::new(),
back_button: button::State::new(),
next_button: button::State::new(),
debug: false,
},
Command::none(),
)
}
}
fn title(&self) -> String {
format!("{} - Iced", self.steps.title())
}
fn update(&mut self, event: Message) -> Command<Message> {
fn update(&mut self, event: Message) {
match event {
Message::BackPressed => {
self.steps.go_back();
@ -53,8 +47,6 @@ impl Application for Tour {
self.steps.update(step_msg, &mut self.debug);
}
}
Command::none()
}
fn view(&mut self) -> Element<Message> {