Purify Animation API and introduce application::timed

This commit is contained in:
Héctor Ramón Jiménez 2025-04-29 03:03:32 +02:00
parent 4334923add
commit 29a19fcde1
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
9 changed files with 281 additions and 104 deletions

View file

@ -11,7 +11,7 @@ use iced::{
pub fn main() -> iced::Result {
tracing_subscriber::fmt::init();
iced::application(Clock::default, Clock::update, Clock::view)
iced::application(Clock::new, Clock::update, Clock::view)
.subscription(Clock::subscription)
.theme(Clock::theme)
.run()
@ -28,6 +28,13 @@ enum Message {
}
impl Clock {
fn new() -> Self {
Self {
now: chrono::offset::Local::now(),
clock: Cache::default(),
}
}
fn update(&mut self, message: Message) {
match message {
Message::Tick(local_time) => {
@ -58,15 +65,6 @@ impl Clock {
}
}
impl Default for Clock {
fn default() -> Self {
Self {
now: chrono::offset::Local::now(),
clock: Cache::default(),
}
}
}
impl<Message> canvas::Program<Message> for Clock {
type State = ();