AppEvent (#61)
Extend `events` to provide a `mpsc` channel to send `AppEvent`'s from anywhere in the app straight to the `App`.
This commit is contained in:
parent
d3c436da0b
commit
8f50bc5fc6
146
src/app.rs
146
src/app.rs
@ -2,7 +2,8 @@ use crate::{
|
|||||||
args::Args,
|
args::Args,
|
||||||
common::{AppEditMode, AppTime, AppTimeFormat, Content, Notification, Style},
|
common::{AppEditMode, AppTime, AppTimeFormat, Content, Notification, Style},
|
||||||
constants::TICK_VALUE_MS,
|
constants::TICK_VALUE_MS,
|
||||||
events::{Event, EventHandler, Events},
|
events,
|
||||||
|
events::TuiEventHandler,
|
||||||
storage::AppStorage,
|
storage::AppStorage,
|
||||||
terminal::Terminal,
|
terminal::Terminal,
|
||||||
widgets::{
|
widgets::{
|
||||||
@ -60,13 +61,21 @@ pub struct AppArgs {
|
|||||||
pub current_value_countdown: Duration,
|
pub current_value_countdown: Duration,
|
||||||
pub elapsed_value_countdown: Duration,
|
pub elapsed_value_countdown: Duration,
|
||||||
pub current_value_timer: Duration,
|
pub current_value_timer: Duration,
|
||||||
|
pub app_tx: events::AppEventTx,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Getting `AppArgs` by merging `Args` and `AppStorage`.
|
pub struct FromAppArgs {
|
||||||
/// `Args` wins btw.
|
pub args: Args,
|
||||||
impl From<(Args, AppStorage)> for AppArgs {
|
pub stg: AppStorage,
|
||||||
fn from((args, stg): (Args, AppStorage)) -> Self {
|
pub app_tx: events::AppEventTx,
|
||||||
AppArgs {
|
}
|
||||||
|
|
||||||
|
/// Creates an `App` by merging `Args` and `AppStorage` (`Args` wins)
|
||||||
|
/// and adding `AppEventTx`
|
||||||
|
impl From<FromAppArgs> for App {
|
||||||
|
fn from(args: FromAppArgs) -> Self {
|
||||||
|
let FromAppArgs { args, stg, app_tx } = args;
|
||||||
|
App::new(AppArgs {
|
||||||
with_decis: args.decis || stg.with_decis,
|
with_decis: args.decis || stg.with_decis,
|
||||||
show_menu: args.menu || stg.show_menu,
|
show_menu: args.menu || stg.show_menu,
|
||||||
notification: args.notification.unwrap_or(stg.notification),
|
notification: args.notification.unwrap_or(stg.notification),
|
||||||
@ -85,7 +94,8 @@ impl From<(Args, AppStorage)> for AppArgs {
|
|||||||
current_value_countdown: args.countdown.unwrap_or(stg.current_value_countdown),
|
current_value_countdown: args.countdown.unwrap_or(stg.current_value_countdown),
|
||||||
elapsed_value_countdown: stg.elapsed_value_countdown,
|
elapsed_value_countdown: stg.elapsed_value_countdown,
|
||||||
current_value_timer: stg.current_value_timer,
|
current_value_timer: stg.current_value_timer,
|
||||||
}
|
app_tx,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,8 +124,10 @@ impl App {
|
|||||||
with_decis,
|
with_decis,
|
||||||
pomodoro_mode,
|
pomodoro_mode,
|
||||||
notification,
|
notification,
|
||||||
|
app_tx,
|
||||||
} = args;
|
} = args;
|
||||||
let app_time = get_app_time();
|
let app_time = get_app_time();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
mode: Mode::Running,
|
mode: Mode::Running,
|
||||||
notification,
|
notification,
|
||||||
@ -130,6 +142,7 @@ impl App {
|
|||||||
app_time,
|
app_time,
|
||||||
with_decis,
|
with_decis,
|
||||||
with_notification: notification == Notification::On,
|
with_notification: notification == Notification::On,
|
||||||
|
app_tx: app_tx.clone(),
|
||||||
}),
|
}),
|
||||||
timer: TimerState::new(
|
timer: TimerState::new(
|
||||||
ClockState::<clock::Timer>::new(ClockStateArgs {
|
ClockState::<clock::Timer>::new(ClockStateArgs {
|
||||||
@ -137,6 +150,7 @@ impl App {
|
|||||||
current_value: current_value_timer,
|
current_value: current_value_timer,
|
||||||
tick_value: Duration::from_millis(TICK_VALUE_MS),
|
tick_value: Duration::from_millis(TICK_VALUE_MS),
|
||||||
with_decis,
|
with_decis,
|
||||||
|
app_tx: None,
|
||||||
})
|
})
|
||||||
.with_on_done_by_condition(
|
.with_on_done_by_condition(
|
||||||
notification == Notification::On,
|
notification == Notification::On,
|
||||||
@ -159,33 +173,84 @@ impl App {
|
|||||||
current_value_pause,
|
current_value_pause,
|
||||||
with_decis,
|
with_decis,
|
||||||
with_notification: notification == Notification::On,
|
with_notification: notification == Notification::On,
|
||||||
|
app_tx: app_tx.clone(),
|
||||||
}),
|
}),
|
||||||
footer: FooterState::new(show_menu, app_time_format),
|
footer: FooterState::new(show_menu, app_time_format),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run(mut self, mut terminal: Terminal, mut events: Events) -> Result<Self> {
|
pub async fn run(
|
||||||
|
mut self,
|
||||||
|
terminal: &mut Terminal,
|
||||||
|
mut events: events::Events,
|
||||||
|
) -> Result<Self> {
|
||||||
|
// Closure to handle `KeyEvent`'s
|
||||||
|
let handle_key_event = |app: &mut Self, key: KeyEvent| {
|
||||||
|
debug!("Received key {:?}", key.code);
|
||||||
|
match key.code {
|
||||||
|
KeyCode::Char('q') | KeyCode::Esc => app.mode = Mode::Quit,
|
||||||
|
KeyCode::Char('c') => app.content = Content::Countdown,
|
||||||
|
KeyCode::Char('t') => app.content = Content::Timer,
|
||||||
|
KeyCode::Char('p') => app.content = Content::Pomodoro,
|
||||||
|
// toogle app time format
|
||||||
|
KeyCode::Char(':') => app.footer.toggle_app_time_format(),
|
||||||
|
// toogle menu
|
||||||
|
KeyCode::Char('m') => app.footer.set_show_menu(!app.footer.get_show_menu()),
|
||||||
|
KeyCode::Char(',') => {
|
||||||
|
app.style = app.style.next();
|
||||||
|
}
|
||||||
|
KeyCode::Char('.') => {
|
||||||
|
app.with_decis = !app.with_decis;
|
||||||
|
// update clocks
|
||||||
|
app.timer.set_with_decis(app.with_decis);
|
||||||
|
app.countdown.set_with_decis(app.with_decis);
|
||||||
|
app.pomodoro.set_with_decis(app.with_decis);
|
||||||
|
}
|
||||||
|
KeyCode::Up => app.footer.set_show_menu(true),
|
||||||
|
KeyCode::Down => app.footer.set_show_menu(false),
|
||||||
|
_ => {}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
// Closure to handle `TuiEvent`'s
|
||||||
|
let mut handle_tui_events = |app: &mut Self, event: events::TuiEvent| -> Result<()> {
|
||||||
|
if matches!(event, events::TuiEvent::Tick) {
|
||||||
|
app.app_time = get_app_time();
|
||||||
|
app.countdown.set_app_time(app.app_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pipe events into subviews and handle only 'unhandled' events afterwards
|
||||||
|
if let Some(unhandled) = match app.content {
|
||||||
|
Content::Countdown => app.countdown.update(event.clone()),
|
||||||
|
Content::Timer => app.timer.update(event.clone()),
|
||||||
|
Content::Pomodoro => app.pomodoro.update(event.clone()),
|
||||||
|
} {
|
||||||
|
match unhandled {
|
||||||
|
events::TuiEvent::Render | events::TuiEvent::Resize => {
|
||||||
|
app.draw(terminal)?;
|
||||||
|
}
|
||||||
|
events::TuiEvent::Key(key) => handle_key_event(app, key),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
};
|
||||||
|
|
||||||
|
// Closure to handle `AppEvent`'s
|
||||||
|
let handle_app_events = |_: &mut Self, event: events::AppEvent| -> Result<()> {
|
||||||
|
match event {
|
||||||
|
events::AppEvent::ClockDone => {
|
||||||
|
debug!("AppEvent::ClockDone");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
};
|
||||||
|
|
||||||
while self.is_running() {
|
while self.is_running() {
|
||||||
if let Some(event) = events.next().await {
|
if let Some(event) = events.next().await {
|
||||||
if matches!(event, Event::Tick) {
|
let _ = match event {
|
||||||
self.app_time = get_app_time();
|
events::Event::Terminal(e) => handle_tui_events(&mut self, e),
|
||||||
self.countdown.set_app_time(self.app_time);
|
events::Event::App(e) => handle_app_events(&mut self, e),
|
||||||
}
|
};
|
||||||
|
|
||||||
// Pipe events into subviews and handle only 'unhandled' events afterwards
|
|
||||||
if let Some(unhandled) = match self.content {
|
|
||||||
Content::Countdown => self.countdown.update(event.clone()),
|
|
||||||
Content::Timer => self.timer.update(event.clone()),
|
|
||||||
Content::Pomodoro => self.pomodoro.update(event.clone()),
|
|
||||||
} {
|
|
||||||
match unhandled {
|
|
||||||
Event::Render | Event::Resize => {
|
|
||||||
self.draw(&mut terminal)?;
|
|
||||||
}
|
|
||||||
Event::Key(key) => self.handle_key_event(key),
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(self)
|
Ok(self)
|
||||||
@ -240,33 +305,6 @@ impl App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_key_event(&mut self, key: KeyEvent) {
|
|
||||||
debug!("Received key {:?}", key.code);
|
|
||||||
match key.code {
|
|
||||||
KeyCode::Char('q') | KeyCode::Esc => self.mode = Mode::Quit,
|
|
||||||
KeyCode::Char('c') => self.content = Content::Countdown,
|
|
||||||
KeyCode::Char('t') => self.content = Content::Timer,
|
|
||||||
KeyCode::Char('p') => self.content = Content::Pomodoro,
|
|
||||||
// toogle app time format
|
|
||||||
KeyCode::Char(':') => self.footer.toggle_app_time_format(),
|
|
||||||
// toogle menu
|
|
||||||
KeyCode::Char('m') => self.footer.set_show_menu(!self.footer.get_show_menu()),
|
|
||||||
KeyCode::Char(',') => {
|
|
||||||
self.style = self.style.next();
|
|
||||||
}
|
|
||||||
KeyCode::Char('.') => {
|
|
||||||
self.with_decis = !self.with_decis;
|
|
||||||
// update clocks
|
|
||||||
self.timer.set_with_decis(self.with_decis);
|
|
||||||
self.countdown.set_with_decis(self.with_decis);
|
|
||||||
self.pomodoro.set_with_decis(self.with_decis);
|
|
||||||
}
|
|
||||||
KeyCode::Up => self.footer.set_show_menu(true),
|
|
||||||
KeyCode::Down => self.footer.set_show_menu(false),
|
|
||||||
_ => {}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(&mut self, terminal: &mut Terminal) -> Result<()> {
|
fn draw(&mut self, terminal: &mut Terminal) -> Result<()> {
|
||||||
terminal.draw(|frame| {
|
terminal.draw(|frame| {
|
||||||
frame.render_stateful_widget(AppWidget, frame.area(), self);
|
frame.render_stateful_widget(AppWidget, frame.area(), self);
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
use crossterm::event::{Event as CrosstermEvent, EventStream, KeyEvent, KeyEventKind};
|
use crossterm::event::{Event as CrosstermEvent, EventStream, KeyEvent, KeyEventKind};
|
||||||
use futures::{Stream, StreamExt};
|
use futures::{Stream, StreamExt};
|
||||||
use std::{pin::Pin, time::Duration};
|
use std::{pin::Pin, time::Duration};
|
||||||
|
use tokio::sync::mpsc;
|
||||||
use tokio::time::interval;
|
use tokio::time::interval;
|
||||||
use tokio_stream::{wrappers::IntervalStream, StreamMap};
|
use tokio_stream::{wrappers::IntervalStream, StreamMap};
|
||||||
|
|
||||||
@ -12,8 +13,9 @@ enum StreamKey {
|
|||||||
Render,
|
Render,
|
||||||
Crossterm,
|
Crossterm,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Event {
|
pub enum TuiEvent {
|
||||||
Error,
|
Error,
|
||||||
Tick,
|
Tick,
|
||||||
Render,
|
Render,
|
||||||
@ -21,8 +23,17 @@ pub enum Event {
|
|||||||
Resize,
|
Resize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub enum AppEvent {
|
||||||
|
ClockDone,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type AppEventTx = mpsc::UnboundedSender<AppEvent>;
|
||||||
|
pub type AppEventRx = mpsc::UnboundedReceiver<AppEvent>;
|
||||||
|
|
||||||
pub struct Events {
|
pub struct Events {
|
||||||
streams: StreamMap<StreamKey, Pin<Box<dyn Stream<Item = Event>>>>,
|
streams: StreamMap<StreamKey, Pin<Box<dyn Stream<Item = TuiEvent>>>>,
|
||||||
|
app_channel: (AppEventTx, AppEventRx),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Events {
|
impl Default for Events {
|
||||||
@ -33,31 +44,46 @@ impl Default for Events {
|
|||||||
(StreamKey::Render, render_stream()),
|
(StreamKey::Render, render_stream()),
|
||||||
(StreamKey::Crossterm, crossterm_stream()),
|
(StreamKey::Crossterm, crossterm_stream()),
|
||||||
]),
|
]),
|
||||||
|
app_channel: mpsc::unbounded_channel(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum Event {
|
||||||
|
Terminal(TuiEvent),
|
||||||
|
App(AppEvent),
|
||||||
|
}
|
||||||
|
|
||||||
impl Events {
|
impl Events {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn next(&mut self) -> Option<Event> {
|
pub async fn next(&mut self) -> Option<Event> {
|
||||||
self.streams.next().await.map(|(_, event)| event)
|
let streams = &mut self.streams;
|
||||||
|
let app_rx = &mut self.app_channel.1;
|
||||||
|
tokio::select! {
|
||||||
|
Some((_, event)) = streams.next() => Some(Event::Terminal(event)),
|
||||||
|
Some(app_event) = app_rx.recv() => Some(Event::App(app_event)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_app_event_tx(&self) -> AppEventTx {
|
||||||
|
self.app_channel.0.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tick_stream() -> Pin<Box<dyn Stream<Item = Event>>> {
|
fn tick_stream() -> Pin<Box<dyn Stream<Item = TuiEvent>>> {
|
||||||
let tick_interval = interval(Duration::from_millis(TICK_VALUE_MS));
|
let tick_interval = interval(Duration::from_millis(TICK_VALUE_MS));
|
||||||
Box::pin(IntervalStream::new(tick_interval).map(|_| Event::Tick))
|
Box::pin(IntervalStream::new(tick_interval).map(|_| TuiEvent::Tick))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_stream() -> Pin<Box<dyn Stream<Item = Event>>> {
|
fn render_stream() -> Pin<Box<dyn Stream<Item = TuiEvent>>> {
|
||||||
let render_interval = interval(Duration::from_millis(FPS_VALUE_MS));
|
let render_interval = interval(Duration::from_millis(FPS_VALUE_MS));
|
||||||
Box::pin(IntervalStream::new(render_interval).map(|_| Event::Render))
|
Box::pin(IntervalStream::new(render_interval).map(|_| TuiEvent::Render))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn crossterm_stream() -> Pin<Box<dyn Stream<Item = Event>>> {
|
fn crossterm_stream() -> Pin<Box<dyn Stream<Item = TuiEvent>>> {
|
||||||
Box::pin(
|
Box::pin(
|
||||||
EventStream::new()
|
EventStream::new()
|
||||||
.fuse()
|
.fuse()
|
||||||
@ -65,16 +91,16 @@ fn crossterm_stream() -> Pin<Box<dyn Stream<Item = Event>>> {
|
|||||||
.filter_map(|event| async move {
|
.filter_map(|event| async move {
|
||||||
match event {
|
match event {
|
||||||
Ok(CrosstermEvent::Key(key)) if key.kind == KeyEventKind::Press => {
|
Ok(CrosstermEvent::Key(key)) if key.kind == KeyEventKind::Press => {
|
||||||
Some(Event::Key(key))
|
Some(TuiEvent::Key(key))
|
||||||
}
|
}
|
||||||
Ok(CrosstermEvent::Resize(_, _)) => Some(Event::Resize),
|
Ok(CrosstermEvent::Resize(_, _)) => Some(TuiEvent::Resize),
|
||||||
Err(_) => Some(Event::Error),
|
Err(_) => Some(TuiEvent::Error),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait EventHandler {
|
pub trait TuiEventHandler {
|
||||||
fn update(&mut self, _: Event) -> Option<Event>;
|
fn update(&mut self, _: TuiEvent) -> Option<TuiEvent>;
|
||||||
}
|
}
|
||||||
|
|||||||
15
src/main.rs
15
src/main.rs
@ -13,7 +13,7 @@ mod terminal;
|
|||||||
mod utils;
|
mod utils;
|
||||||
mod widgets;
|
mod widgets;
|
||||||
|
|
||||||
use app::{App, AppArgs};
|
use app::{App, FromAppArgs};
|
||||||
use args::Args;
|
use args::Args;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
@ -30,7 +30,7 @@ async fn main() -> Result<()> {
|
|||||||
// get args given by CLI
|
// get args given by CLI
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
let terminal = terminal::setup()?;
|
let mut terminal = terminal::setup()?;
|
||||||
let events = events::Events::new();
|
let events = events::Events::new();
|
||||||
|
|
||||||
// check persistant storage
|
// check persistant storage
|
||||||
@ -42,9 +42,14 @@ async fn main() -> Result<()> {
|
|||||||
storage.load().unwrap_or_default()
|
storage.load().unwrap_or_default()
|
||||||
};
|
};
|
||||||
|
|
||||||
// merge `Args` and `AppStorage`.
|
let app_storage = App::from(FromAppArgs {
|
||||||
let app_args = AppArgs::from((args, stg));
|
args,
|
||||||
let app_storage = App::new(app_args).run(terminal, events).await?.to_storage();
|
stg,
|
||||||
|
app_tx: events.get_app_event_tx(),
|
||||||
|
})
|
||||||
|
.run(&mut terminal, events)
|
||||||
|
.await?
|
||||||
|
.to_storage();
|
||||||
// store app state persistantly
|
// store app state persistantly
|
||||||
storage.save(app_storage)?;
|
storage.save(app_storage)?;
|
||||||
|
|
||||||
|
|||||||
29
src/sound.rs
Normal file
29
src/sound.rs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
use rodio::{Decoder, OutputStream, Sink};
|
||||||
|
use std::fs;
|
||||||
|
|
||||||
|
pub struct Sound {
|
||||||
|
sound_data: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Sound {
|
||||||
|
pub fn new(path: &str) -> Result<Self, String> {
|
||||||
|
let sound_data = fs::read(path).map_err(|e| format!("Failed to read sound file: {}", e))?;
|
||||||
|
Ok(Self { sound_data })
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn play(&self) -> Result<(), String> {
|
||||||
|
let (_stream, stream_handle) = OutputStream::try_default()
|
||||||
|
.map_err(|e| format!("Failed to get audio output: {}", e))?;
|
||||||
|
|
||||||
|
let sink = Sink::try_new(&stream_handle)
|
||||||
|
.map_err(|e| format!("Failed to create audio sink: {}", e))?;
|
||||||
|
|
||||||
|
let cursor = std::io::Cursor::new(self.sound_data.clone());
|
||||||
|
let source = Decoder::new(cursor).map_err(|e| format!("Failed to decode audio: {}", e))?;
|
||||||
|
|
||||||
|
sink.append(source);
|
||||||
|
sink.sleep_until_end();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,6 +12,7 @@ use ratatui::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
common::Style,
|
common::Style,
|
||||||
duration::{DurationEx, MAX_DURATION, ONE_DECI_SECOND, ONE_HOUR, ONE_MINUTE, ONE_SECOND},
|
duration::{DurationEx, MAX_DURATION, ONE_DECI_SECOND, ONE_HOUR, ONE_MINUTE, ONE_SECOND},
|
||||||
|
events::{AppEvent, AppEventTx},
|
||||||
utils::center_horizontal,
|
utils::center_horizontal,
|
||||||
widgets::clock_elements::{
|
widgets::clock_elements::{
|
||||||
Colon, Digit, Dot, COLON_WIDTH, DIGIT_HEIGHT, DIGIT_SPACE_WIDTH, DIGIT_WIDTH, DOT_WIDTH,
|
Colon, Digit, Dot, COLON_WIDTH, DIGIT_HEIGHT, DIGIT_SPACE_WIDTH, DIGIT_WIDTH, DOT_WIDTH,
|
||||||
@ -73,6 +74,7 @@ pub struct ClockState<T> {
|
|||||||
format: Format,
|
format: Format,
|
||||||
pub with_decis: bool,
|
pub with_decis: bool,
|
||||||
on_done: Option<Box<dyn Fn() + 'static>>,
|
on_done: Option<Box<dyn Fn() + 'static>>,
|
||||||
|
app_tx: Option<AppEventTx>,
|
||||||
phantom: PhantomData<T>,
|
phantom: PhantomData<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +83,7 @@ pub struct ClockStateArgs {
|
|||||||
pub current_value: Duration,
|
pub current_value: Duration,
|
||||||
pub tick_value: Duration,
|
pub tick_value: Duration,
|
||||||
pub with_decis: bool,
|
pub with_decis: bool,
|
||||||
|
pub app_tx: Option<AppEventTx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> ClockState<T> {
|
impl<T> ClockState<T> {
|
||||||
@ -329,6 +332,9 @@ impl<T> ClockState<T> {
|
|||||||
if let Some(handler) = &mut self.on_done {
|
if let Some(handler) = &mut self.on_done {
|
||||||
handler();
|
handler();
|
||||||
};
|
};
|
||||||
|
if let Some(tx) = &mut self.app_tx {
|
||||||
|
_ = tx.send(AppEvent::ClockDone);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,6 +369,7 @@ impl ClockState<Countdown> {
|
|||||||
current_value,
|
current_value,
|
||||||
tick_value,
|
tick_value,
|
||||||
with_decis,
|
with_decis,
|
||||||
|
app_tx,
|
||||||
} = args;
|
} = args;
|
||||||
let mut instance = Self {
|
let mut instance = Self {
|
||||||
initial_value: initial_value.into(),
|
initial_value: initial_value.into(),
|
||||||
@ -378,6 +385,7 @@ impl ClockState<Countdown> {
|
|||||||
format: Format::S,
|
format: Format::S,
|
||||||
with_decis,
|
with_decis,
|
||||||
on_done: None,
|
on_done: None,
|
||||||
|
app_tx,
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
};
|
};
|
||||||
// update format once
|
// update format once
|
||||||
@ -432,6 +440,7 @@ impl ClockState<Timer> {
|
|||||||
current_value,
|
current_value,
|
||||||
tick_value,
|
tick_value,
|
||||||
with_decis,
|
with_decis,
|
||||||
|
app_tx,
|
||||||
} = args;
|
} = args;
|
||||||
let mut instance = Self {
|
let mut instance = Self {
|
||||||
initial_value: initial_value.into(),
|
initial_value: initial_value.into(),
|
||||||
@ -447,6 +456,7 @@ impl ClockState<Timer> {
|
|||||||
format: Format::S,
|
format: Format::S,
|
||||||
with_decis,
|
with_decis,
|
||||||
on_done: None,
|
on_done: None,
|
||||||
|
app_tx,
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
};
|
};
|
||||||
// update format once
|
// update format once
|
||||||
|
|||||||
@ -11,6 +11,7 @@ fn test_toggle_edit() {
|
|||||||
current_value: ONE_HOUR,
|
current_value: ONE_HOUR,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: true,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
// off by default
|
// off by default
|
||||||
assert!(!c.is_edit_mode());
|
assert!(!c.is_edit_mode());
|
||||||
@ -29,6 +30,7 @@ fn test_default_edit_mode_hhmmss() {
|
|||||||
current_value: ONE_HOUR,
|
current_value: ONE_HOUR,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: true,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -43,6 +45,7 @@ fn test_default_edit_mode_mmss() {
|
|||||||
current_value: ONE_MINUTE,
|
current_value: ONE_MINUTE,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: true,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
// toggle on
|
// toggle on
|
||||||
c.toggle_edit();
|
c.toggle_edit();
|
||||||
@ -56,6 +59,7 @@ fn test_default_edit_mode_ss() {
|
|||||||
current_value: ONE_SECOND,
|
current_value: ONE_SECOND,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: true,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
// toggle on
|
// toggle on
|
||||||
c.toggle_edit();
|
c.toggle_edit();
|
||||||
@ -69,6 +73,7 @@ fn test_edit_next_hhmmssd() {
|
|||||||
current_value: ONE_HOUR,
|
current_value: ONE_HOUR,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: true,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -90,6 +95,7 @@ fn test_edit_next_hhmmss() {
|
|||||||
current_value: ONE_HOUR,
|
current_value: ONE_HOUR,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: false,
|
with_decis: false,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -109,6 +115,7 @@ fn test_edit_next_mmssd() {
|
|||||||
current_value: ONE_MINUTE,
|
current_value: ONE_MINUTE,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: true,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -128,6 +135,7 @@ fn test_edit_next_mmss() {
|
|||||||
current_value: ONE_MINUTE,
|
current_value: ONE_MINUTE,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: false,
|
with_decis: false,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -145,6 +153,7 @@ fn test_edit_next_ssd() {
|
|||||||
current_value: ONE_SECOND * 3,
|
current_value: ONE_SECOND * 3,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: true,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -160,6 +169,7 @@ fn test_edit_next_ss() {
|
|||||||
current_value: ONE_SECOND * 3,
|
current_value: ONE_SECOND * 3,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: false,
|
with_decis: false,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -176,6 +186,7 @@ fn test_edit_prev_hhmmssd() {
|
|||||||
current_value: ONE_HOUR,
|
current_value: ONE_HOUR,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: true,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -196,6 +207,7 @@ fn test_edit_prev_hhmmss() {
|
|||||||
current_value: ONE_HOUR,
|
current_value: ONE_HOUR,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: false,
|
with_decis: false,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -214,6 +226,7 @@ fn test_edit_prev_mmssd() {
|
|||||||
current_value: ONE_MINUTE,
|
current_value: ONE_MINUTE,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: true,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -234,6 +247,7 @@ fn test_edit_prev_mmss() {
|
|||||||
current_value: ONE_MINUTE,
|
current_value: ONE_MINUTE,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: false,
|
with_decis: false,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -252,6 +266,7 @@ fn test_edit_prev_ssd() {
|
|||||||
current_value: ONE_SECOND,
|
current_value: ONE_SECOND,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: true,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -270,6 +285,7 @@ fn test_edit_prev_ss() {
|
|||||||
current_value: ONE_SECOND,
|
current_value: ONE_SECOND,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: false,
|
with_decis: false,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -285,7 +301,8 @@ fn test_edit_up_ss() {
|
|||||||
initial_value: Duration::ZERO,
|
initial_value: Duration::ZERO,
|
||||||
current_value: Duration::ZERO,
|
current_value: Duration::ZERO,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: false,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -301,7 +318,8 @@ fn test_edit_up_mmss() {
|
|||||||
initial_value: Duration::ZERO,
|
initial_value: Duration::ZERO,
|
||||||
current_value: Duration::from_secs(60),
|
current_value: Duration::from_secs(60),
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: false,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -320,7 +338,8 @@ fn test_edit_up_hhmmss() {
|
|||||||
initial_value: Duration::ZERO,
|
initial_value: Duration::ZERO,
|
||||||
current_value: Duration::from_secs(3600),
|
current_value: Duration::from_secs(3600),
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: false,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -341,7 +360,8 @@ fn test_edit_down_ss() {
|
|||||||
initial_value: Duration::ZERO,
|
initial_value: Duration::ZERO,
|
||||||
current_value: ONE_SECOND,
|
current_value: ONE_SECOND,
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: false,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -361,7 +381,8 @@ fn test_edit_down_mmss() {
|
|||||||
initial_value: Duration::ZERO,
|
initial_value: Duration::ZERO,
|
||||||
current_value: Duration::from_secs(120),
|
current_value: Duration::from_secs(120),
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: false,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
@ -383,7 +404,8 @@ fn test_edit_down_hhmmss() {
|
|||||||
initial_value: Duration::ZERO,
|
initial_value: Duration::ZERO,
|
||||||
current_value: Duration::from_secs(3600),
|
current_value: Duration::from_secs(3600),
|
||||||
tick_value: ONE_DECI_SECOND,
|
tick_value: ONE_DECI_SECOND,
|
||||||
with_decis: false,
|
with_decis: true,
|
||||||
|
app_tx: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// toggle on
|
// toggle on
|
||||||
|
|||||||
@ -2,11 +2,11 @@ use crate::{
|
|||||||
common::{AppTime, Style},
|
common::{AppTime, Style},
|
||||||
constants::TICK_VALUE_MS,
|
constants::TICK_VALUE_MS,
|
||||||
duration::{DurationEx, MAX_DURATION},
|
duration::{DurationEx, MAX_DURATION},
|
||||||
events::{Event, EventHandler},
|
events::{AppEventTx, TuiEvent, TuiEventHandler},
|
||||||
utils::center,
|
utils::center,
|
||||||
widgets::{
|
widgets::{
|
||||||
clock::{self, ClockState, ClockStateArgs, ClockWidget, Mode as ClockMode},
|
clock::{self, ClockState, ClockStateArgs, ClockWidget, Mode as ClockMode},
|
||||||
edit_time::EditTimeState,
|
edit_time::{EditTimeState, EditTimeStateArgs, EditTimeWidget},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -25,8 +25,6 @@ use std::ops::Sub;
|
|||||||
use std::{cmp::max, time::Duration};
|
use std::{cmp::max, time::Duration};
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
|
|
||||||
use super::edit_time::{EditTimeStateArgs, EditTimeWidget};
|
|
||||||
|
|
||||||
pub struct CountdownStateArgs {
|
pub struct CountdownStateArgs {
|
||||||
pub initial_value: Duration,
|
pub initial_value: Duration,
|
||||||
pub current_value: Duration,
|
pub current_value: Duration,
|
||||||
@ -34,6 +32,7 @@ pub struct CountdownStateArgs {
|
|||||||
pub app_time: AppTime,
|
pub app_time: AppTime,
|
||||||
pub with_decis: bool,
|
pub with_decis: bool,
|
||||||
pub with_notification: bool,
|
pub with_notification: bool,
|
||||||
|
pub app_tx: AppEventTx,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// State for Countdown Widget
|
/// State for Countdown Widget
|
||||||
@ -56,6 +55,7 @@ impl CountdownState {
|
|||||||
with_notification,
|
with_notification,
|
||||||
with_decis,
|
with_decis,
|
||||||
app_time,
|
app_time,
|
||||||
|
app_tx,
|
||||||
} = args;
|
} = args;
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
@ -64,6 +64,7 @@ impl CountdownState {
|
|||||||
current_value,
|
current_value,
|
||||||
tick_value: Duration::from_millis(TICK_VALUE_MS),
|
tick_value: Duration::from_millis(TICK_VALUE_MS),
|
||||||
with_decis,
|
with_decis,
|
||||||
|
app_tx: Some(app_tx.clone()),
|
||||||
})
|
})
|
||||||
.with_on_done_by_condition(with_notification, || {
|
.with_on_done_by_condition(with_notification, || {
|
||||||
debug!("on_done COUNTDOWN");
|
debug!("on_done COUNTDOWN");
|
||||||
@ -79,6 +80,7 @@ impl CountdownState {
|
|||||||
current_value: elapsed_value,
|
current_value: elapsed_value,
|
||||||
tick_value: Duration::from_millis(TICK_VALUE_MS),
|
tick_value: Duration::from_millis(TICK_VALUE_MS),
|
||||||
with_decis: false,
|
with_decis: false,
|
||||||
|
app_tx: None,
|
||||||
})
|
})
|
||||||
// A previous `elapsed_value > 0` means the `Clock` was running before,
|
// A previous `elapsed_value > 0` means the `Clock` was running before,
|
||||||
// but not in `Initial` state anymore. Updating `Mode` here
|
// but not in `Initial` state anymore. Updating `Mode` here
|
||||||
@ -154,12 +156,12 @@ impl CountdownState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventHandler for CountdownState {
|
impl TuiEventHandler for CountdownState {
|
||||||
fn update(&mut self, event: Event) -> Option<Event> {
|
fn update(&mut self, event: TuiEvent) -> Option<TuiEvent> {
|
||||||
let is_edit_clock = self.clock.is_edit_mode();
|
let is_edit_clock = self.clock.is_edit_mode();
|
||||||
let is_edit_time = self.edit_time.is_some();
|
let is_edit_time = self.edit_time.is_some();
|
||||||
match event {
|
match event {
|
||||||
Event::Tick => {
|
TuiEvent::Tick => {
|
||||||
if !self.clock.is_done() {
|
if !self.clock.is_done() {
|
||||||
self.clock.tick();
|
self.clock.tick();
|
||||||
} else {
|
} else {
|
||||||
@ -175,7 +177,7 @@ impl EventHandler for CountdownState {
|
|||||||
edit_time.set_max_time(max_time);
|
edit_time.set_max_time(max_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Key(key) => match key.code {
|
TuiEvent::Key(key) => match key.code {
|
||||||
KeyCode::Char('r') => {
|
KeyCode::Char('r') => {
|
||||||
// reset both clocks to use intial values
|
// reset both clocks to use intial values
|
||||||
self.clock.reset();
|
self.clock.reset();
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
common::Style,
|
common::Style,
|
||||||
constants::TICK_VALUE_MS,
|
constants::TICK_VALUE_MS,
|
||||||
events::{Event, EventHandler},
|
events::{AppEventTx, TuiEvent, TuiEventHandler},
|
||||||
utils::center,
|
utils::center,
|
||||||
widgets::clock::{ClockState, ClockStateArgs, ClockWidget, Countdown},
|
widgets::clock::{ClockState, ClockStateArgs, ClockWidget, Countdown},
|
||||||
};
|
};
|
||||||
@ -57,6 +57,7 @@ pub struct PomodoroStateArgs {
|
|||||||
pub current_value_pause: Duration,
|
pub current_value_pause: Duration,
|
||||||
pub with_decis: bool,
|
pub with_decis: bool,
|
||||||
pub with_notification: bool,
|
pub with_notification: bool,
|
||||||
|
pub app_tx: AppEventTx,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PomodoroState {
|
impl PomodoroState {
|
||||||
@ -69,6 +70,7 @@ impl PomodoroState {
|
|||||||
current_value_pause,
|
current_value_pause,
|
||||||
with_decis,
|
with_decis,
|
||||||
with_notification,
|
with_notification,
|
||||||
|
app_tx,
|
||||||
} = args;
|
} = args;
|
||||||
Self {
|
Self {
|
||||||
mode,
|
mode,
|
||||||
@ -78,6 +80,7 @@ impl PomodoroState {
|
|||||||
current_value: current_value_work,
|
current_value: current_value_work,
|
||||||
tick_value: Duration::from_millis(TICK_VALUE_MS),
|
tick_value: Duration::from_millis(TICK_VALUE_MS),
|
||||||
with_decis,
|
with_decis,
|
||||||
|
app_tx: Some(app_tx.clone()),
|
||||||
})
|
})
|
||||||
.with_on_done_by_condition(with_notification, || {
|
.with_on_done_by_condition(with_notification, || {
|
||||||
debug!("on_done WORK");
|
debug!("on_done WORK");
|
||||||
@ -93,6 +96,7 @@ impl PomodoroState {
|
|||||||
current_value: current_value_pause,
|
current_value: current_value_pause,
|
||||||
tick_value: Duration::from_millis(TICK_VALUE_MS),
|
tick_value: Duration::from_millis(TICK_VALUE_MS),
|
||||||
with_decis,
|
with_decis,
|
||||||
|
app_tx: Some(app_tx),
|
||||||
})
|
})
|
||||||
.with_on_done_by_condition(with_notification, || {
|
.with_on_done_by_condition(with_notification, || {
|
||||||
debug!("on_done PAUSE");
|
debug!("on_done PAUSE");
|
||||||
@ -140,14 +144,14 @@ impl PomodoroState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventHandler for PomodoroState {
|
impl TuiEventHandler for PomodoroState {
|
||||||
fn update(&mut self, event: Event) -> Option<Event> {
|
fn update(&mut self, event: TuiEvent) -> Option<TuiEvent> {
|
||||||
let edit_mode = self.get_clock().is_edit_mode();
|
let edit_mode = self.get_clock().is_edit_mode();
|
||||||
match event {
|
match event {
|
||||||
Event::Tick => {
|
TuiEvent::Tick => {
|
||||||
self.get_clock_mut().tick();
|
self.get_clock_mut().tick();
|
||||||
}
|
}
|
||||||
Event::Key(key) => match key.code {
|
TuiEvent::Key(key) => match key.code {
|
||||||
KeyCode::Char('s') => {
|
KeyCode::Char('s') => {
|
||||||
self.get_clock_mut().toggle_pause();
|
self.get_clock_mut().toggle_pause();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
common::Style,
|
common::Style,
|
||||||
events::{Event, EventHandler},
|
events::{TuiEvent, TuiEventHandler},
|
||||||
utils::center,
|
utils::center,
|
||||||
widgets::clock::{self, ClockState, ClockWidget},
|
widgets::clock::{self, ClockState, ClockWidget},
|
||||||
};
|
};
|
||||||
@ -31,14 +31,14 @@ impl TimerState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventHandler for TimerState {
|
impl TuiEventHandler for TimerState {
|
||||||
fn update(&mut self, event: Event) -> Option<Event> {
|
fn update(&mut self, event: TuiEvent) -> Option<TuiEvent> {
|
||||||
let edit_mode = self.clock.is_edit_mode();
|
let edit_mode = self.clock.is_edit_mode();
|
||||||
match event {
|
match event {
|
||||||
Event::Tick => {
|
TuiEvent::Tick => {
|
||||||
self.clock.tick();
|
self.clock.tick();
|
||||||
}
|
}
|
||||||
Event::Key(key) => match key.code {
|
TuiEvent::Key(key) => match key.code {
|
||||||
KeyCode::Char('s') => {
|
KeyCode::Char('s') => {
|
||||||
self.clock.toggle_pause();
|
self.clock.toggle_pause();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user