Purify Animation API and introduce application::timed
This commit is contained in:
parent
4334923add
commit
29a19fcde1
9 changed files with 281 additions and 104 deletions
|
|
@ -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 = ();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue