47 lines
1.5 KiB
Rust
47 lines
1.5 KiB
Rust
use std::error::Error;
|
|
|
|
use ratatui::{
|
|
Frame, Terminal,
|
|
layout::{
|
|
Alignment,
|
|
Constraint::{Length, Min, Percentage},
|
|
Layout,
|
|
},
|
|
widgets::{Block, Borders},
|
|
};
|
|
|
|
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 pomodoro_block = Block::bordered().title("Pomodoro");
|
|
|
|
frame.render_widget(pomodoro_block, pomodoro_area);
|
|
|
|
let utilities_layout = Layout::horizontal([Percentage(75), Percentage(25)]);
|
|
let [pomodori, controls] = utilities_layout.areas(utilities_area);
|
|
|
|
let pomodori_block = Block::bordered().title("Pomodori");
|
|
let controls_block = Block::bordered().title("Controls");
|
|
|
|
frame.render_widget(pomodori_block, pomodori);
|
|
frame.render_widget(controls_block, controls);
|
|
}
|