diff options
| author | Saiyed Shizain <saiyedshizain@gmail.com> | 2026-01-18 21:02:45 +0530 |
|---|---|---|
| committer | Saiyed Shizain <saiyedshizain@gmail.com> | 2026-01-18 21:02:45 +0530 |
| commit | bb66e0f10c86f3b2e5a3a8c20d910c4df8d05ac7 (patch) | |
| tree | a5907978eec8d26184ed4817cb844da111d944e1 /src/pomo/state.rs | |
| parent | 8f4d471f3b3a6d25b0ba3d3c2b9abbdce7d20312 (diff) | |
| download | pomoru-bb66e0f10c86f3b2e5a3a8c20d910c4df8d05ac7.tar.xz pomoru-bb66e0f10c86f3b2e5a3a8c20d910c4df8d05ac7.zip | |
idiomatic rust
Diffstat (limited to 'src/pomo/state.rs')
| -rw-r--r-- | src/pomo/state.rs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/pomo/state.rs b/src/pomo/state.rs new file mode 100644 index 0000000..111e935 --- /dev/null +++ b/src/pomo/state.rs @@ -0,0 +1,49 @@ +use ratatui::widgets::ListState; +use std::time::Duration; + +#[derive(PartialEq, Clone, Copy)] +pub enum SessionMode { + Work, + ShortBreak, + LongBreak, +} + +pub struct Task { + pub title: String, + pub is_done: bool, +} + +pub struct Pomo { + pub mode: SessionMode, + pub time_remaining: Duration, + pub is_running: bool, + pub tasks: Vec<Task>, + pub task_state: ListState, + pub should_quit: bool, +} + +impl Pomo { + pub fn new() -> Self { + Self { + mode: SessionMode::Work, + time_remaining: Duration::from_secs(25 * 60), + is_running: false, + tasks: Vec::new(), + task_state: ListState::default(), + should_quit: false, + } + } + + pub fn tick(&mut self) { + if self.is_running && self.time_remaining.as_secs() > 0 { + self.time_remaining -= Duration::from_secs(1); + } else if self.time_remaining.as_secs() == 0 { + self.is_running = false; + // logic for switching modes will go here + } + } + + pub fn toggle_timer(&mut self) { + self.is_running = !self.is_running; + } +} |