aboutsummaryrefslogtreecommitdiff
path: root/src/pomo
diff options
context:
space:
mode:
authorRanXom <saiyedshizain@gmail.com>2026-06-12 22:26:45 +0530
committerRanXom <saiyedshizain@gmail.com>2026-06-12 22:26:45 +0530
commit54ba8a74344090404a963db551e0e5170210026d (patch)
treee566c85edda86a9963d3ddd9728f4ec971ed5fa1 /src/pomo
parentae5c7a9fd635af703b87422e178adf8c71cd9893 (diff)
downloadpomoru-54ba8a74344090404a963db551e0e5170210026d.tar.xz
pomoru-54ba8a74344090404a963db551e0e5170210026d.zip
introduce auto switch session field in Pomo struct
Diffstat (limited to 'src/pomo')
-rw-r--r--src/pomo/state.rs42
-rw-r--r--src/pomo/ui.rs106
2 files changed, 55 insertions, 93 deletions
diff --git a/src/pomo/state.rs b/src/pomo/state.rs
index c9eb496..46c2dc1 100644
--- a/src/pomo/state.rs
+++ b/src/pomo/state.rs
@@ -40,15 +40,23 @@ impl Default for Theme {
surface0: Color::Rgb(49, 50, 68),
text: Color::Rgb(205, 214, 244),
};
-
+
if let Some(base_dirs) = BaseDirs::new() {
let path = base_dirs.home_dir().join(".config/noctalia/colors.json");
if let Ok(content) = fs::read_to_string(&path) {
if let Ok(colors) = serde_json::from_str::<NoctaliaColors>(&content) {
- if let Some(c) = parse_hex_color(&colors.m_primary) { theme.primary = c; }
- if let Some(c) = parse_hex_color(&colors.m_on_surface_variant) { theme.overlay0 = c; }
- if let Some(c) = parse_hex_color(&colors.m_surface_variant) { theme.surface0 = c; }
- if let Some(c) = parse_hex_color(&colors.m_on_surface) { theme.text = c; }
+ if let Some(c) = parse_hex_color(&colors.m_primary) {
+ theme.primary = c;
+ }
+ if let Some(c) = parse_hex_color(&colors.m_on_surface_variant) {
+ theme.overlay0 = c;
+ }
+ if let Some(c) = parse_hex_color(&colors.m_surface_variant) {
+ theme.surface0 = c;
+ }
+ if let Some(c) = parse_hex_color(&colors.m_on_surface) {
+ theme.text = c;
+ }
}
}
}
@@ -101,6 +109,7 @@ pub struct Pomo {
pub time_remaining: Duration,
pub total_duration: Duration,
pub is_running: bool,
+ pub auto_switch_sessions: bool,
pub break_count: u32,
pub tasks: Vec<Task>,
pub task_state: ListState,
@@ -122,6 +131,7 @@ impl Pomo {
time_remaining: work,
total_duration: work,
is_running: false,
+ auto_switch_sessions: true,
break_count: 0,
tasks: Vec::new(),
task_state: ListState::default(),
@@ -148,17 +158,21 @@ impl Pomo {
"Ref! Do Something! The break's over!",
];
- // Use the remaining duration/break count as a seed for simple 'random' selection
- let idx = (self.break_count as usize) % 4;
+ if self.auto_switch_sessions {
+ // Use the remaining duration/break count as a seed for simple 'random' selection
+ let idx = (self.break_count as usize) % 4;
- let (title, msg) = match self.mode {
- SessionMode::Work => ("Focus Block Complete", focus_msg[idx]),
- _ => ("Break Over", break_msg[idx]),
- };
+ let (title, msg) = match self.mode {
+ SessionMode::Work => ("Focus Block Complete", focus_msg[idx]),
+ _ => ("Break Over", break_msg[idx]),
+ };
- self.send_notification(title, msg);
- self.transition_next_session();
- self.is_running = true;
+ self.send_notification(title, msg);
+ self.transition_next_session();
+ self.is_running = true;
+ } else {
+ // TODO: Handle manual session switching
+ }
}
}
diff --git a/src/pomo/ui.rs b/src/pomo/ui.rs
index 3559ece..70f880e 100644
--- a/src/pomo/ui.rs
+++ b/src/pomo/ui.rs
@@ -27,7 +27,16 @@ pub fn render(f: &mut Frame, app: &mut Pomo) {
render_timer_screen(f, app, timer_v_center[1]);
- let footer = "tab session • t tasks • e edit time • space pause • r reset • q quit";
+ let auto_switch = if app.auto_switch_sessions {
+ "a next: auto"
+ } else {
+ "a next: manual"
+ };
+
+ let footer = format!(
+ "tab session • t tasks • e edit time • space pause • r reset • {} • q quit",
+ auto_switch
+ );
f.render_widget(
Paragraph::new(footer)
.alignment(Alignment::Center)
@@ -89,83 +98,17 @@ fn format_monolithic_ascii(time: &str) -> Text<'static> {
let mut lines = vec![String::new(); 5];
for (idx, c) in time.chars().enumerate() {
let art = match c {
- '0' => vec![
- " ██████ ",
- "██ ██",
- "██ ██",
- "██ ██",
- " ██████ "
- ],
- '1' => vec![
- " ██ ",
- " ███ ",
- " ██ ",
- " ██ ",
- " ██████ "
- ],
- '2' => vec![
- " ██████ ",
- "██ ██",
- " ███ ",
- " ███ ",
- "████████"
- ],
- '3' => vec![
- " ██████ ",
- " ██",
- " █████ ",
- " ██",
- " ██████ "
- ],
- '4' => vec![
- "██ ██",
- "██ ██",
- "████████",
- " ██",
- " ██"
- ],
- '5' => vec![
- "████████",
- "██ ",
- "███████ ",
- " ██",
- "███████ "
- ],
- '6' => vec![
- " ██████ ",
- "██ ",
- "███████ ",
- "██ ██",
- " ██████ "
- ],
- '7' => vec![
- "████████",
- " ██",
- " ██ ",
- " ██ ",
- " ██ "
- ],
- '8' => vec![
- " ██████ ",
- "██ ██",
- " ██████ ",
- "██ ██",
- " ██████ "
- ],
- '9' => vec![
- " ██████ ",
- "██ ██",
- " ███████",
- " ██",
- " ██████ "
- ],
- ':' => vec![
- " ",
- " █ ",
- " ",
- " █ ",
- " "
- ],
+ '0' => vec![" ██████ ", "██ ██", "██ ██", "██ ██", " ██████ "],
+ '1' => vec![" ██ ", " ███ ", " ██ ", " ██ ", " ██████ "],
+ '2' => vec![" ██████ ", "██ ██", " ███ ", " ███ ", "████████"],
+ '3' => vec![" ██████ ", " ██", " █████ ", " ██", " ██████ "],
+ '4' => vec!["██ ██", "██ ██", "████████", " ██", " ██"],
+ '5' => vec!["████████", "██ ", "███████ ", " ██", "███████ "],
+ '6' => vec![" ██████ ", "██ ", "███████ ", "██ ██", " ██████ "],
+ '7' => vec!["████████", " ██", " ██ ", " ██ ", " ██ "],
+ '8' => vec![" ██████ ", "██ ██", " ██████ ", "██ ██", " ██████ "],
+ '9' => vec![" ██████ ", "██ ██", " ███████", " ██", " ██████ "],
+ ':' => vec![" ", " █ ", " ", " █ ", " "],
_ => vec![" "; 5],
};
for i in 0..5 {
@@ -235,7 +178,12 @@ pub fn render_task_screen(f: &mut Frame, app: &mut Pomo, footer_area: Rect) {
.padding(Padding::uniform(1))
.border_style(Style::default().fg(app.theme.primary)),
)
- .highlight_style(Style::default().bg(app.theme.surface0).fg(app.theme.text).bold())
+ .highlight_style(
+ Style::default()
+ .bg(app.theme.surface0)
+ .fg(app.theme.text)
+ .bold(),
+ )
.highlight_symbol(">> ");
f.render_stateful_widget(list, area, &mut app.task_state);