Moving Workflow

Moving all work over to staging to accomodate workflow going forward.

Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
2025-09-11 17:39:20 -04:00
parent c9a968e1cf
commit 1a94332ef8
8 changed files with 984 additions and 0 deletions

0
src/cli.rs Normal file
View File

42
src/lib.rs Normal file
View File

@@ -0,0 +1,42 @@
use crossterm::event::{self, Event, KeyCode};
use std::{error::Error, time::Duration};
pub mod cli;
pub mod pomodoro;
pub mod ui;
use ui::draw_ui;
pub fn run() -> Result<(), Box<dyn Error>> {
let mut keep_running;
let mut terminal = ratatui::init();
loop {
draw_ui(&mut terminal)?;
keep_running = process_events()?;
if !keep_running {
break;
}
}
ratatui::restore();
Ok(())
}
fn process_events() -> Result<bool, Box<dyn Error>> {
if !event::poll(Duration::from_secs(0))? {
return Ok(true);
}
if let Event::Key(key) = event::read()? {
return Ok(handle_key(key.code));
}
Ok(true)
}
fn handle_key(code: KeyCode) -> bool {
if let KeyCode::Char('q') = code {
return false;
}
true
}

8
src/main.rs Normal file
View File

@@ -0,0 +1,8 @@
use pomodoro_timer::run;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
run()?;
Ok(())
}

0
src/pomodoro.rs Normal file
View File

54
src/ui.rs Normal file
View File

@@ -0,0 +1,54 @@
use std::error::Error;
use ratatui::{
Frame, Terminal,
layout::{
Alignment,
Constraint::{Length, Min, Percentage},
Layout,
},
widgets::{Block, Borders, Gauge},
};
pub fn draw_ui<B: ratatui::backend::Backend>(
terminal: &mut Terminal<B>,
) -> Result<(), Box<dyn Error>> {
terminal.draw(draw)?;
Ok(())
}
fn draw(frame: &mut Frame) {
let main_layout = Layout::vertical([Length(1), Min(0), Length(1)]);
let [title_bar, app_area, status_bar] = main_layout.areas(frame.area());
let title_block = Block::new().borders(Borders::TOP).title("Pomodoro Timer");
let status_block = Block::new()
.borders(Borders::TOP)
.title("By: Wesley Irvin (c) 2025")
.title_alignment(Alignment::Right);
frame.render_widget(title_block, title_bar);
frame.render_widget(status_block, status_bar);
let timer_layout = Layout::vertical([Percentage(65), Percentage(35)]);
let [pomodoro_area, utilities_area] = timer_layout.areas(app_area);
let timer_label = format!("{}:{} / 25:00", 17, 32);
let timer_ratio = (17 * 60 + 32) as f64 / (25 * 60) as f64;
let pomodoro_timer = Gauge::default()
.block(Block::bordered().title("Pomodoro"))
.label(timer_label)
.ratio(timer_ratio);
frame.render_widget(pomodoro_timer, pomodoro_area);
let utilities_layout = Layout::horizontal([Percentage(75), Percentage(25)]);
let [pomodori, controls] = utilities_layout.areas(utilities_area);
let pomodori_completed = Gauge::default()
.block(Block::bordered().title("Pomodori"))
.label("3 / 4")
.ratio(0.75);
let controls_block = Block::bordered().title("Controls");
frame.render_widget(pomodori_completed, pomodori);
frame.render_widget(controls_block, controls);
}