summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-17 07:09:46 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-17 07:11:44 +0100
commit02c20e6202f1c8c28753f3233cc635790707937a (patch)
treeb13ec79b938a6000709d1241ac1344724386c77a /examples
parente640b875900a3833fd38efa195e99b40ec3f6820 (diff)
downloadiced-02c20e6202f1c8c28753f3233cc635790707937a.tar.gz
iced-02c20e6202f1c8c28753f3233cc635790707937a.tar.bz2
iced-02c20e6202f1c8c28753f3233cc635790707937a.zip
Support async actions in `iced_winit`
Diffstat (limited to 'examples')
-rw-r--r--examples/scroll.rs14
-rw-r--r--examples/todos.rs14
-rw-r--r--examples/tour.rs36
3 files changed, 40 insertions, 24 deletions
diff --git a/examples/scroll.rs b/examples/scroll.rs
index 50701879..61ad2a53 100644
--- a/examples/scroll.rs
+++ b/examples/scroll.rs
@@ -1,12 +1,12 @@
use iced::{
- button, scrollable, Align, Application, Button, Container, Element, Image,
- Length, Scrollable, Text,
+ button, scrollable, Align, Application, Button, Command, Container,
+ Element, Image, Length, Scrollable, Text,
};
pub fn main() {
env_logger::init();
- Example::default().run()
+ Example::run()
}
#[derive(Default)]
@@ -25,16 +25,22 @@ pub enum Message {
impl Application for Example {
type Message = Message;
+ fn new() -> (Example, Command<Message>) {
+ (Example::default(), Command::none())
+ }
+
fn title(&self) -> String {
String::from("Scroll - Iced")
}
- fn update(&mut self, message: Message) {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::AddItem => {
self.item_count += 1;
}
}
+
+ Command::none()
}
fn view(&mut self) -> Element<Message> {
diff --git a/examples/todos.rs b/examples/todos.rs
index f921a666..d97a9e08 100644
--- a/examples/todos.rs
+++ b/examples/todos.rs
@@ -1,11 +1,11 @@
use iced::{
button, scrollable, text::HorizontalAlignment, text_input, Align,
- Application, Background, Button, Checkbox, Color, Column, Container,
- Element, Font, Length, Row, Scrollable, Text, TextInput,
+ Application, Background, Button, Checkbox, Color, Column, Command,
+ Container, Element, Font, Length, Row, Scrollable, Text, TextInput,
};
pub fn main() {
- Todos::default().run()
+ Todos::run()
}
#[derive(Debug, Default)]
@@ -29,11 +29,15 @@ pub enum Message {
impl Application for Todos {
type Message = Message;
+ fn new() -> (Todos, Command<Message>) {
+ (Todos::default(), Command::none())
+ }
+
fn title(&self) -> String {
String::from("Todos - Iced")
}
- fn update(&mut self, message: Message) {
+ fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::InputChanged(value) => {
self.input_value = value;
@@ -58,6 +62,8 @@ impl Application for Todos {
}
dbg!(self);
+
+ Command::none()
}
fn view(&mut self) -> Element<Message> {
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> {