Introduce subscription::Event

... and remove `PlatformSpecific` from `Event`
This commit is contained in:
Héctor Ramón Jiménez 2024-06-11 19:41:05 +02:00
parent 83296a73eb
commit 5d7dcf417c
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
13 changed files with 156 additions and 129 deletions

View file

@ -1,4 +1,4 @@
use iced::event::{self, Event};
use iced::event;
use iced::widget::{center, text};
use iced::{Element, Subscription};
@ -15,27 +15,20 @@ struct App {
#[derive(Debug, Clone)]
enum Message {
EventOccurred(Event),
UrlReceived(String),
}
impl App {
fn update(&mut self, message: Message) {
match message {
Message::EventOccurred(event) => {
if let Event::PlatformSpecific(
event::PlatformSpecific::MacOS(event::MacOS::ReceivedUrl(
url,
)),
) = event
{
self.url = Some(url);
}
Message::UrlReceived(url) => {
self.url = Some(url);
}
}
}
fn subscription(&self) -> Subscription<Message> {
event::listen().map(Message::EventOccurred)
event::listen_url().map(Message::UrlReceived)
}
fn view(&self) -> Element<Message> {