summaryrefslogtreecommitdiffstats
path: root/examples/url_handler/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-03-16 17:09:00 +0100
committerLibravatar GitHub <noreply@github.com>2024-03-16 17:09:00 +0100
commit503a48e89977437bf8b7bf485f416a15a2e83ed0 (patch)
tree30306bbaee7a31090ace9d7725d46c2c0027fe6b /examples/url_handler/src
parent0524e9b4571d264018656418f02a1f9e27e268d7 (diff)
parentcfc0383bbfff083786840e3f1fd499e5991fa629 (diff)
downloadiced-503a48e89977437bf8b7bf485f416a15a2e83ed0.tar.gz
iced-503a48e89977437bf8b7bf485f416a15a2e83ed0.tar.bz2
iced-503a48e89977437bf8b7bf485f416a15a2e83ed0.zip
Merge pull request #2331 from iced-rs/program-api
`Program` API
Diffstat (limited to 'examples/url_handler/src')
-rw-r--r--examples/url_handler/src/main.rs30
1 files changed, 7 insertions, 23 deletions
diff --git a/examples/url_handler/src/main.rs b/examples/url_handler/src/main.rs
index bf570123..f16b9051 100644
--- a/examples/url_handler/src/main.rs
+++ b/examples/url_handler/src/main.rs
@@ -1,12 +1,11 @@
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("URL Handler - Iced", App::update, App::view)
+ .subscription(App::subscription)
+ .run()
}
#[derive(Debug, Default)]
@@ -19,21 +18,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 +31,7 @@ impl Application for App {
self.url = Some(url);
}
}
- };
-
- Command::none()
+ }
}
fn subscription(&self) -> Subscription<Message> {