feat(event) desktop notification at event time (#124)

This commit is contained in:
Jens Krause 2025-10-10 10:50:50 +02:00 committed by GitHub
parent 6b6221803c
commit 758a72fbf6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 5 deletions

View File

@ -213,7 +213,7 @@ impl App {
event: EventState::new(EventStateArgs {
app_time,
event_time: time::PrimitiveDateTime::parse(
"2025-10-09 21:32:30",
"2025-10-10 10:30:30",
format_description!("[year]-[month]-[day] [hour]:[minute]:[second]"),
)
.unwrap(),

View File

@ -25,6 +25,7 @@ pub enum Content {
pub enum ClockTypeId {
Countdown,
Timer,
Event,
}
#[derive(Debug, Copy, Clone, ValueEnum, Default, Serialize, Deserialize)]

View File

@ -7,9 +7,9 @@ use ratatui::{
use time::{OffsetDateTime, macros::format_description};
use crate::{
common::{AppTime, Style},
common::{AppTime, ClockTypeId, Style},
duration::CalendarDuration,
events::{AppEventTx, TuiEvent, TuiEventHandler},
events::{AppEvent, AppEventTx, TuiEvent, TuiEventHandler},
utils::center,
widgets::{clock, clock_elements::DIGIT_HEIGHT},
};
@ -25,6 +25,7 @@ pub struct EventState {
/// counter to simulate `DONE` state
/// Default value: `None`
done_count: Option<u64>,
app_tx: AppEventTx,
}
pub struct EventStateArgs {
@ -45,8 +46,6 @@ impl EventState {
app_tx,
} = args;
// TODO: Handle app Events
let _ = app_tx;
let app_datetime = OffsetDateTime::from(app_time);
// assume event has as same `offset` as `app_time`
let event_offset = event_time.assume_offset(app_datetime.offset());
@ -58,6 +57,7 @@ impl EventState {
start_time: app_datetime,
with_decis,
done_count: None,
app_tx,
}
}
@ -91,6 +91,10 @@ impl EventState {
if duration < Duration::from_millis(100) {
// reset `done_count`
self.done_count = Some(clock::MAX_DONE_COUNT);
// send notification
_ = self
.app_tx
.send(AppEvent::ClockDone(ClockTypeId::Event, self.title.clone()));
}
// count (possible) `done`
self.done_count = clock::count_clock_done(self.done_count);