diff options
| author | RanXom <saiyedshizain@gmail.com> | 2026-06-13 00:00:31 +0530 |
|---|---|---|
| committer | RanXom <saiyedshizain@gmail.com> | 2026-06-13 00:00:31 +0530 |
| commit | e2cd4834f116b35e0a61666368d8fc93382fc38e (patch) | |
| tree | 0971bd9d1f38eae59f30b4db1ab1c7b11f73aa46 /src | |
| parent | 93f970097c1d1f3b8369c0876c1d1894af6978d5 (diff) | |
| download | pomoru-e2cd4834f116b35e0a61666368d8fc93382fc38e.tar.xz pomoru-e2cd4834f116b35e0a61666368d8fc93382fc38e.zip | |
add current status generator
Diffstat (limited to 'src')
| -rw-r--r-- | src/pomo/mod.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs index 1d6ae34..242c1df 100644 --- a/src/pomo/mod.rs +++ b/src/pomo/mod.rs @@ -1,7 +1,10 @@ pub mod state; pub mod ui; -use crate::pomo::state::{AppScreen, Config, InputMode, Pomo, SessionMode, Task}; +use crate::pomo::{ + state::{AppScreen, Config, CurrentStatus, InputMode, Pomo, SessionMode, Task}, + ui::format_duration, +}; use crossterm::{ event::{self, Event, KeyCode}, execute, @@ -12,6 +15,26 @@ use ratatui::prelude::*; use std::{fs, io, time::Duration}; impl Pomo { + pub fn current_status(&self) -> CurrentStatus { + let class = match self.mode { + SessionMode::ShortBreak => "short-break", + SessionMode::LongBreak => "long-break", + SessionMode::Work => "work", + }; + + let tooltip = match self.mode { + SessionMode::ShortBreak => "Short Break", + SessionMode::LongBreak => "Long Break", + SessionMode::Work => "Work", + }; + + CurrentStatus { + text: format_duration(self.time_remaining), + tooltip: tooltip.to_string(), + class: class.to_string(), + } + } + pub fn save(&self) -> Result<(), Box<dyn std::error::Error>> { let config = Config { work_time_mins: self.work_time.as_secs() / 60, |