summaryrefslogtreecommitdiffstats
path: root/examples/tour.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2019-11-18 23:06:28 +0100
committerLibravatar GitHub <noreply@github.com>2019-11-18 23:06:28 +0100
commit5adefdf6613bfe0738b573eab1d280fa041f5417 (patch)
tree60ff05b3ee9e896d9538de19bb2412c7d6e63c6a /examples/tour.rs
parent54ffefcc0b8f4558a93ca51f044594db009bacc8 (diff)
parent63dbf078fefea444073813e834c2d35fa25eb3a7 (diff)
downloadiced-5adefdf6613bfe0738b573eab1d280fa041f5417.tar.gz
iced-5adefdf6613bfe0738b573eab1d280fa041f5417.tar.bz2
iced-5adefdf6613bfe0738b573eab1d280fa041f5417.zip
Merge pull request #62 from hecrj/feature/async-actions
Async actions
Diffstat (limited to 'examples/tour.rs')
-rw-r--r--examples/tour.rs36
1 files changed, 20 insertions, 16 deletions
diff --git a/examples/tour.rs b/examples/tour.rs
index 34ad0a34..6d7a080f 100644
--- a/examples/tour.rs
+++ b/examples/tour.rs
@@ -1,13 +1,14 @@
use iced::{
button, scrollable, slider, text::HorizontalAlignment, text_input,
- Application, Background, Button, Checkbox, Color, Column, Container,
- Element, Image, Length, Radio, Row, Scrollable, Slider, Text, TextInput,
+ Application, Background, Button, Checkbox, Color, Column, Command,
+ Container, Element, Image, Length, Radio, Row, Scrollable, Slider, Text,
+ TextInput,
};
pub fn main() {
env_logger::init();
- Tour::new().run()
+ Tour::run()
}
pub struct Tour {
@@ -18,26 +19,27 @@ pub struct Tour {
debug: bool,
}
-impl Tour {
- pub fn new() -> Tour {
- Tour {
- steps: Steps::new(),
- scroll: scrollable::State::new(),
- back_button: button::State::new(),
- next_button: button::State::new(),
- debug: true,
- }
- }
-}
-
impl Application for Tour {
type Message = Message;
+ fn new() -> (Tour, Command<Message>) {
+ (
+ Tour {
+ steps: Steps::new(),
+ scroll: scrollable::State::new(),
+ back_button: button::State::new(),
+ next_button: button::State::new(),
+ debug: true,
+ },
+ Command::none(),
+ )
+ }
+
fn title(&self) -> String {
format!("{} - Iced", self.steps.title())
}
- fn update(&mut self, event: Message) {
+ fn update(&mut self, event: Message) -> Command<Message> {
match event {
Message::BackPressed => {
self.steps.go_back();
@@ -49,6 +51,8 @@ impl Application for Tour {
self.steps.update(step_msg, &mut self.debug);
}
}
+
+ Command::none()
}
fn view(&mut self) -> Element<Message> {