From 59ef24f2c27f762a5dff37e1cfd06c6f1cbb68cc Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 17 Mar 2024 18:41:46 +0100 Subject: Use `Program` API in `modal` example --- examples/modal/src/main.rs | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'examples/modal') diff --git a/examples/modal/src/main.rs b/examples/modal/src/main.rs index e1fc04c0..398728e0 100644 --- a/examples/modal/src/main.rs +++ b/examples/modal/src/main.rs @@ -1,20 +1,19 @@ use iced::event::{self, Event}; -use iced::executor; use iced::keyboard; use iced::keyboard::key; use iced::widget::{ self, button, column, container, horizontal_space, pick_list, row, text, text_input, }; -use iced::{ - Alignment, Application, Command, Element, Length, Settings, Subscription, -}; +use iced::{Alignment, Command, Element, Length, Subscription}; use modal::Modal; use std::fmt; pub fn main() -> iced::Result { - App::run(Settings::default()) + iced::program("Modal - Iced", App::update, App::view) + .subscription(App::subscription) + .run() } #[derive(Default)] @@ -36,21 +35,8 @@ enum Message { Event(Event), } -impl Application for App { - type Executor = executor::Default; - type Message = Message; - type Theme = iced::Theme; - type Flags = (); - - fn new(_flags: ()) -> (Self, Command) { - (App::default(), Command::none()) - } - - fn title(&self) -> String { - String::from("Modal - Iced") - } - - fn subscription(&self) -> Subscription { +impl App { + fn subscription(&self) -> Subscription { event::listen().map(Message::Event) } -- cgit