Static UI
Got a basic static UI layout setup. Just needs to be plugged up with actual logic to animate. Maybe new frames to follow.
This commit is contained in:
18
src/ui.rs
18
src/ui.rs
@@ -7,7 +7,7 @@ use ratatui::{
|
|||||||
Constraint::{Length, Min, Percentage},
|
Constraint::{Length, Min, Percentage},
|
||||||
Layout,
|
Layout,
|
||||||
},
|
},
|
||||||
widgets::{Block, Borders},
|
widgets::{Block, Borders, Gauge},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn draw_ui<B: ratatui::backend::Backend>(
|
pub fn draw_ui<B: ratatui::backend::Backend>(
|
||||||
@@ -31,16 +31,24 @@ fn draw(frame: &mut Frame) {
|
|||||||
|
|
||||||
let timer_layout = Layout::vertical([Percentage(65), Percentage(35)]);
|
let timer_layout = Layout::vertical([Percentage(65), Percentage(35)]);
|
||||||
let [pomodoro_area, utilities_area] = timer_layout.areas(app_area);
|
let [pomodoro_area, utilities_area] = timer_layout.areas(app_area);
|
||||||
let pomodoro_block = Block::bordered().title("Pomodoro");
|
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_block, pomodoro_area);
|
frame.render_widget(pomodoro_timer, pomodoro_area);
|
||||||
|
|
||||||
let utilities_layout = Layout::horizontal([Percentage(75), Percentage(25)]);
|
let utilities_layout = Layout::horizontal([Percentage(75), Percentage(25)]);
|
||||||
let [pomodori, controls] = utilities_layout.areas(utilities_area);
|
let [pomodori, controls] = utilities_layout.areas(utilities_area);
|
||||||
|
|
||||||
let pomodori_block = Block::bordered().title("Pomodori");
|
let pomodori_completed = Gauge::default()
|
||||||
|
.block(Block::bordered().title("Pomodori"))
|
||||||
|
.label("3 / 4")
|
||||||
|
.ratio(0.75);
|
||||||
let controls_block = Block::bordered().title("Controls");
|
let controls_block = Block::bordered().title("Controls");
|
||||||
|
|
||||||
frame.render_widget(pomodori_block, pomodori);
|
frame.render_widget(pomodori_completed, pomodori);
|
||||||
frame.render_widget(controls_block, controls);
|
frame.render_widget(controls_block, controls);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user