summaryrefslogtreecommitdiffstats
path: root/examples/exit
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-16 05:33:47 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-16 05:33:47 +0100
commitc22269bff3085012d326a0df77bf27ad5bcb41b7 (patch)
tree1083f21d012ab2bac88fb51537d4dc431bc7f170 /examples/exit
parent0524e9b4571d264018656418f02a1f9e27e268d7 (diff)
downloadiced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.gz
iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.bz2
iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.zip
Introduce `Program` API
Diffstat (limited to 'examples/exit')
-rw-r--r--examples/exit/src/main.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/examples/exit/src/main.rs b/examples/exit/src/main.rs
index ec618dc1..dc78b0bb 100644
--- a/examples/exit/src/main.rs
+++ b/examples/exit/src/main.rs
@@ -1,10 +1,11 @@
-use iced::executor;
use iced::widget::{button, column, container};
use iced::window;
-use iced::{Alignment, Application, Command, Element, Length, Settings, Theme};
+use iced::{Alignment, Command, Element, Length};
pub fn main() -> iced::Result {
- Exit::run(Settings::default())
+ iced::application(Exit::new, Exit::update, Exit::view)
+ .title("Exit - Iced")
+ .run()
}
#[derive(Default)]
@@ -18,20 +19,11 @@ enum Message {
Exit,
}
-impl Application for Exit {
- type Executor = executor::Default;
- type Message = Message;
- type Theme = Theme;
- type Flags = ();
-
- fn new(_flags: ()) -> (Self, Command<Message>) {
+impl Exit {
+ fn new() -> (Self, Command<Message>) {
(Self::default(), Command::none())
}
- fn title(&self) -> String {
- String::from("Exit - Iced")
- }
-
fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::Confirm => window::close(window::Id::MAIN),