feat(countdown): persist elapsed time (#46)
This commit is contained in:
@@ -91,6 +91,27 @@ pub struct ClockStateArgs {
|
||||
}
|
||||
|
||||
impl<T> ClockState<T> {
|
||||
pub fn with_mode(mut self, mode: Mode) -> Self {
|
||||
self.mode = mode;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn get_mode(&self) -> &Mode {
|
||||
&self.mode
|
||||
}
|
||||
|
||||
pub fn is_initial(&self) -> bool {
|
||||
self.mode == Mode::Initial
|
||||
}
|
||||
|
||||
pub fn run(&mut self) {
|
||||
self.mode = Mode::Tick
|
||||
}
|
||||
|
||||
pub fn is_running(&self) -> bool {
|
||||
self.mode == Mode::Tick
|
||||
}
|
||||
|
||||
pub fn toggle_pause(&mut self) {
|
||||
self.mode = if self.mode == Mode::Tick {
|
||||
Mode::Pause
|
||||
@@ -185,6 +206,7 @@ impl<T> ClockState<T> {
|
||||
};
|
||||
self.update_format();
|
||||
}
|
||||
|
||||
pub fn edit_current_down(&mut self) {
|
||||
self.current_value = match self.mode {
|
||||
Mode::Editable(Time::Decis, _) => {
|
||||
@@ -203,22 +225,6 @@ impl<T> ClockState<T> {
|
||||
self.update_mode();
|
||||
}
|
||||
|
||||
pub fn get_mode(&self) -> &Mode {
|
||||
&self.mode
|
||||
}
|
||||
|
||||
pub fn run(&mut self) {
|
||||
self.mode = Mode::Tick
|
||||
}
|
||||
|
||||
pub fn is_running(&self) -> bool {
|
||||
self.mode == Mode::Tick
|
||||
}
|
||||
|
||||
pub fn is_initial(&self) -> bool {
|
||||
self.mode == Mode::Initial
|
||||
}
|
||||
|
||||
pub fn is_edit_mode(&self) -> bool {
|
||||
matches!(self.mode, Mode::Editable(_, _))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user