1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
use ratatui::{prelude::*, widgets::*};
use crate::pomo::state::{Pomo, AppScreen, SessionMode, InputMode};
const MOCHA_LAVENDER: Color = Color::Rgb(180, 190, 254);
const MOCHA_OVERLAY0: Color = Color::Rgb(108, 112, 134);
const MOCHA_SURFACE0: Color = Color::Rgb(49, 50, 68);
const MOCHA_TEXT: Color = Color::Rgb(205, 214, 244);
pub fn render(f: &mut Frame, app: &mut Pomo) {
let main_block = Block::default().style(Style::default().bg(Color::Reset));
f.render_widget(main_block, f.area());
let root_layout = Layout::default()
.direction(Direction::Vertical)
.constraints([
Constraint::Min(0), // App Screen Content
Constraint::Length(1), // Absolute Footer
Constraint::Length(1), // Bottom Padding Spacer
])
.split(f.area());
match app.screen {
AppScreen::Timer => {
let timer_v_center = Layout::default()
.direction(Direction::Vertical)
.constraints([
Constraint::Fill(1),
Constraint::Length(15),
Constraint::Fill(1),
])
.split(root_layout[0]);
render_timer_screen(f, app, timer_v_center[1]);
let footer = "tab session • e edit time • space pause • r reset • q quit";
f.render_widget(
Paragraph::new(footer)
.alignment(Alignment::Center)
.style(Style::default().fg(MOCHA_OVERLAY0)),
root_layout[1]
);
}
AppScreen::Tasks => {
render_task_screen(f, app, root_layout[1]);
}
}
if let InputMode::Insert | InputMode::Edit | InputMode::TimerEdit = app.input_mode {
render_input_modal(f, app);
}
}
fn render_timer_screen(f: &mut Frame, app: &Pomo, area: Rect) {
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([
Constraint::Length(1), // Priority Text
Constraint::Length(4), // Spacer
Constraint::Length(5), // ASCII Timer
Constraint::Length(3), // Spacer
Constraint::Length(1), // Session Dots
Constraint::Min(0),
])
.split(area);
let priority_text = app.tasks.iter().find(|t| !t.is_done)
.map(|t| format!("Current Focus: {}", t.title))
.unwrap_or_else(|| "No Active Tasks".to_string());
f.render_widget(
Paragraph::new(priority_text)
.alignment(Alignment::Center)
.style(Style::default().fg(MOCHA_LAVENDER).bold()),
chunks[0]
);
let time_str = format_duration(app.time_remaining);
let big_text = format_monolithic_ascii(&time_str);
f.render_widget(
Paragraph::new(big_text).alignment(Alignment::Center).style(Style::default().fg(MOCHA_LAVENDER)),
chunks[2]
);
render_session_dots(f, app, chunks[4]);
}
// Fixed-width monolithic ASCII engine
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![" █ ", " ", " █ ", " ", " "],
_ => vec![" "; 5],
};
for i in 0..5 {
lines[i].push_str(art[i]);
if idx < time.len() - 1 { lines[i].push_str(" "); }
}
}
Text::from(lines.into_iter().map(Line::from).collect::<Vec<_>>())
}
fn render_session_dots(f: &mut Frame, app: &Pomo, area: Rect) {
let modes = [(SessionMode::Work, "Focus"), (SessionMode::ShortBreak, "Short Break"), (SessionMode::LongBreak, "Long Break")];
let spans = modes.iter().enumerate().map(|(i, (mode, label))| {
let is_active = app.mode == *mode;
let color = if is_active { MOCHA_LAVENDER } else { MOCHA_OVERLAY0 };
let content = if is_active { format!("• {}", label) } else { label.to_string() };
let mut s = vec![Span::styled(content, Style::default().fg(color))];
if i < modes.len() - 1 { s.push(Span::raw(" ")); }
s
}).flatten().collect::<Vec<_>>();
f.render_widget(Paragraph::new(Line::from(spans)).alignment(Alignment::Center), area);
}
pub fn render_task_screen(f: &mut Frame, app: &mut Pomo, footer_area: Rect) {
let area = centered_rect(60, 80, f.area());
let items: Vec<ListItem> = app.tasks.iter().map(|t| {
let symbol = if t.is_done { "" } else { "" };
ListItem::new(Text::from(format!(" {} {}", symbol, t.title)))
}).collect();
let list = List::new(items)
.block(Block::default()
.title(" Focus Priorities ")
.borders(Borders::ALL)
.border_type(BorderType::Rounded)
.padding(Padding::uniform(1))
.border_style(Style::default().fg(MOCHA_LAVENDER)))
.highlight_style(Style::default().bg(MOCHA_SURFACE0).fg(MOCHA_TEXT).bold())
.highlight_symbol(">> ");
f.render_stateful_widget(list, area, &mut app.task_state);
let footer_text = "i insert • ⏎ toggle • e edit • d delete • t back";
f.render_widget(
Paragraph::new(footer_text)
.alignment(Alignment::Center)
.style(Style::default().fg(MOCHA_OVERLAY0)),
footer_area
);
}
pub fn render_input_modal(f: &mut Frame, app: &Pomo) {
// We use a fixed height of 7 to ensure the "center" feels spacious
let area = centered_rect(45, 7, f.area());
f.render_widget(Clear, area);
let title = match app.input_mode {
InputMode::Insert => " New Task ",
InputMode::Edit => " Edit Task ",
InputMode::TimerEdit => " Set Minutes ",
_ => " Input "
};
let block = Block::default()
.title(title)
.borders(Borders::ALL)
.border_t
|