diff options
author | 2024-03-16 05:33:47 +0100 | |
---|---|---|
committer | 2024-03-16 05:33:47 +0100 | |
commit | c22269bff3085012d326a0df77bf27ad5bcb41b7 (patch) | |
tree | 1083f21d012ab2bac88fb51537d4dc431bc7f170 /examples/url_handler | |
parent | 0524e9b4571d264018656418f02a1f9e27e268d7 (diff) | |
download | iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.gz iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.bz2 iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.zip |
Introduce `Program` API
Diffstat (limited to 'examples/url_handler')
-rw-r--r-- | examples/url_handler/src/main.rs | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/examples/url_handler/src/main.rs b/examples/url_handler/src/main.rs index bf570123..f8c18200 100644 --- a/examples/url_handler/src/main.rs +++ b/examples/url_handler/src/main.rs @@ -1,12 +1,12 @@ use iced::event::{self, Event}; -use iced::executor; use iced::widget::{container, text}; -use iced::{ - Application, Command, Element, Length, Settings, Subscription, Theme, -}; +use iced::{Element, Length, Subscription}; pub fn main() -> iced::Result { - App::run(Settings::default()) + iced::sandbox(App::update, App::view) + .subscription(App::subscription) + .title("URL Handler - Iced") + .run() } #[derive(Debug, Default)] @@ -19,21 +19,8 @@ enum Message { EventOccurred(Event), } -impl Application for App { - type Message = Message; - type Theme = Theme; - type Executor = executor::Default; - type Flags = (); - - fn new(_flags: ()) -> (App, Command<Message>) { - (App::default(), Command::none()) - } - - fn title(&self) -> String { - String::from("Url - Iced") - } - - fn update(&mut self, message: Message) -> Command<Message> { +impl App { + fn update(&mut self, message: Message) { match message { Message::EventOccurred(event) => { if let Event::PlatformSpecific( @@ -45,9 +32,7 @@ impl Application for App { self.url = Some(url); } } - }; - - Command::none() + } } fn subscription(&self) -> Subscription<Message> { |