Use Program API in modal example

This commit is contained in:
Héctor Ramón Jiménez 2024-03-17 18:41:46 +01:00
parent acb9321296
commit 59ef24f2c2
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -1,20 +1,19 @@
use iced::event::{self, Event}; use iced::event::{self, Event};
use iced::executor;
use iced::keyboard; use iced::keyboard;
use iced::keyboard::key; use iced::keyboard::key;
use iced::widget::{ use iced::widget::{
self, button, column, container, horizontal_space, pick_list, row, text, self, button, column, container, horizontal_space, pick_list, row, text,
text_input, text_input,
}; };
use iced::{ use iced::{Alignment, Command, Element, Length, Subscription};
Alignment, Application, Command, Element, Length, Settings, Subscription,
};
use modal::Modal; use modal::Modal;
use std::fmt; use std::fmt;
pub fn main() -> iced::Result { pub fn main() -> iced::Result {
App::run(Settings::default()) iced::program("Modal - Iced", App::update, App::view)
.subscription(App::subscription)
.run()
} }
#[derive(Default)] #[derive(Default)]
@ -36,21 +35,8 @@ enum Message {
Event(Event), Event(Event),
} }
impl Application for App { impl App {
type Executor = executor::Default; fn subscription(&self) -> Subscription<Message> {
type Message = Message;
type Theme = iced::Theme;
type Flags = ();
fn new(_flags: ()) -> (Self, Command<Message>) {
(App::default(), Command::none())
}
fn title(&self) -> String {
String::from("Modal - Iced")
}
fn subscription(&self) -> Subscription<Self::Message> {
event::listen().map(Message::Event) event::listen().map(Message::Event)
} }