Use crates.io release of winit 🎉
This commit is contained in:
parent
b11ad9ff5e
commit
8d7aac96d7
9 changed files with 11 additions and 143 deletions
|
|
@ -1,9 +0,0 @@
|
|||
[package]
|
||||
name = "url_handler"
|
||||
version = "0.1.0"
|
||||
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
|
||||
edition = "2024"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
iced.workspace = true
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
use iced::event;
|
||||
use iced::widget::{center, text};
|
||||
use iced::{Element, Subscription};
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
iced::application(App::default, App::update, App::view)
|
||||
.subscription(App::subscription)
|
||||
.run()
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct App {
|
||||
url: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
enum Message {
|
||||
UrlReceived(String),
|
||||
}
|
||||
|
||||
impl App {
|
||||
fn update(&mut self, message: Message) {
|
||||
match message {
|
||||
Message::UrlReceived(url) => {
|
||||
self.url = Some(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn subscription(&self) -> Subscription<Message> {
|
||||
event::listen_url().map(Message::UrlReceived)
|
||||
}
|
||||
|
||||
fn view(&self) -> Element<'_, Message> {
|
||||
let content = match &self.url {
|
||||
Some(url) => text(url),
|
||||
None => text("No URL received yet!"),
|
||||
};
|
||||
|
||||
center(content.size(48)).into()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue