From c4c5216e3b69d732b0518d510f95675a4ba7010b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 30 Mar 2020 18:00:15 +0200 Subject: Allow passing external state to `Application::new` --- examples/clock/src/main.rs | 3 ++- examples/download_progress/src/main.rs | 3 ++- examples/events/src/main.rs | 3 ++- examples/pokedex/src/main.rs | 3 ++- examples/solar_system/src/main.rs | 9 +++++---- examples/stopwatch/src/main.rs | 3 ++- examples/todos/src/main.rs | 3 ++- 7 files changed, 17 insertions(+), 10 deletions(-) (limited to 'examples') diff --git a/examples/clock/src/main.rs b/examples/clock/src/main.rs index d8266f06..1fd19bc6 100644 --- a/examples/clock/src/main.rs +++ b/examples/clock/src/main.rs @@ -23,8 +23,9 @@ enum Message { impl Application for Clock { type Executor = executor::Default; type Message = Message; + type Flags = (); - fn new() -> (Self, Command) { + fn new(_flags: ()) -> (Self, Command) { ( Clock { now: chrono::Local::now().into(), diff --git a/examples/download_progress/src/main.rs b/examples/download_progress/src/main.rs index 6c3094f7..c37ae678 100644 --- a/examples/download_progress/src/main.rs +++ b/examples/download_progress/src/main.rs @@ -26,8 +26,9 @@ pub enum Message { impl Application for Example { type Executor = executor::Default; type Message = Message; + type Flags = (); - fn new() -> (Example, Command) { + fn new(_flags: ()) -> (Example, Command) { ( Example::Idle { button: button::State::new(), diff --git a/examples/events/src/main.rs b/examples/events/src/main.rs index 0c9dca05..066fc230 100644 --- a/examples/events/src/main.rs +++ b/examples/events/src/main.rs @@ -22,8 +22,9 @@ enum Message { impl Application for Events { type Executor = executor::Default; type Message = Message; + type Flags = (); - fn new() -> (Events, Command) { + fn new(_flags: ()) -> (Events, Command) { (Events::default(), Command::none()) } diff --git a/examples/pokedex/src/main.rs b/examples/pokedex/src/main.rs index 4449b901..600ef632 100644 --- a/examples/pokedex/src/main.rs +++ b/examples/pokedex/src/main.rs @@ -29,8 +29,9 @@ enum Message { impl Application for Pokedex { type Executor = iced::executor::Default; type Message = Message; + type Flags = (); - fn new() -> (Pokedex, Command) { + fn new(_flags: ()) -> (Pokedex, Command) { ( Pokedex::Loading, Command::perform(Pokemon::search(), Message::PokemonFound), diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs index 4c239806..1967b7c5 100644 --- a/examples/solar_system/src/main.rs +++ b/examples/solar_system/src/main.rs @@ -7,8 +7,8 @@ //! //! [1]: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations#An_animated_solar_system use iced::{ - canvas, executor, Application, Canvas, Color, Command, Container, Element, - Length, Point, Settings, Size, Subscription, Vector, + canvas, executor, window, Application, Canvas, Color, Command, Container, + Element, Length, Point, Settings, Size, Subscription, Vector, }; use std::time::Instant; @@ -33,8 +33,9 @@ enum Message { impl Application for SolarSystem { type Executor = executor::Default; type Message = Message; + type Flags = (); - fn new() -> (Self, Command) { + fn new(_flags: ()) -> (Self, Command) { ( SolarSystem { state: State::new(), @@ -95,7 +96,7 @@ impl State { pub fn new() -> State { let now = Instant::now(); - let (width, height) = Settings::default().window.size; + let (width, height) = window::Settings::default().size; State { start: now, diff --git a/examples/stopwatch/src/main.rs b/examples/stopwatch/src/main.rs index d84c4817..5a54ed2b 100644 --- a/examples/stopwatch/src/main.rs +++ b/examples/stopwatch/src/main.rs @@ -30,8 +30,9 @@ enum Message { impl Application for Stopwatch { type Executor = iced_futures::executor::AsyncStd; type Message = Message; + type Flags = (); - fn new() -> (Stopwatch, Command) { + fn new(_flags: ()) -> (Stopwatch, Command) { ( Stopwatch { duration: Duration::default(), diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index 7e866b19..c9cbcc69 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -40,8 +40,9 @@ enum Message { impl Application for Todos { type Executor = iced::executor::Default; type Message = Message; + type Flags = (); - fn new() -> (Todos, Command) { + fn new(_flags: ()) -> (Todos, Command) { ( Todos::Loading, Command::perform(SavedState::load(), Message::Loaded), -- cgit