Feature 1: date buttons in EditTask popup

- Add 3 buttons (Today, Tomorrow, Next Week) below Notes
- Popup height increased from 10 to 12
- Tab/Up/Down cycle through 5 fields (Title, Notes, 3 buttons)
- Enter on a date button saves task and sets due date
- Text editing keys restricted to fields 0 and 1
This commit is contained in:
Ruben Rosario
2026-06-21 16:07:16 +01:00
parent b3dcefcd65
commit 747d40b1e9
2 changed files with 62 additions and 18 deletions
+34 -8
View File
@@ -266,9 +266,8 @@ pub fn render_edit_task_popup(
notes_cursor: usize,
active_field: usize,
) {
let popup_area = centered_rect(75, 10, area);
let popup_area = centered_rect(75, 12, area);
// Clear the area first to prevent style/symbol bleed from previously rendered widgets
frame.render_widget(Clear, popup_area);
let outer_block = Block::default()
@@ -280,7 +279,6 @@ pub fn render_edit_task_popup(
frame.render_widget(Clear, popup_area);
frame.render_widget(outer_block, popup_area);
// Split inner area into rows
let rows = Layout::default()
.direction(Direction::Vertical)
.constraints([
@@ -288,6 +286,8 @@ pub fn render_edit_task_popup(
Constraint::Length(1),
Constraint::Length(3),
Constraint::Length(1),
Constraint::Length(1),
Constraint::Length(1),
])
.split(inner_area);
@@ -321,19 +321,45 @@ pub fn render_edit_task_popup(
.block(notes_block);
frame.render_widget(notes_para, rows[2]);
// ── Date buttons row ──
let today_style = if active_field == 2 {
Style::default().fg(FOCUS_COLOR).add_modifier(Modifier::BOLD)
} else {
Style::default().fg(Color::DarkGray)
};
let tomorrow_style = if active_field == 3 {
Style::default().fg(FOCUS_COLOR).add_modifier(Modifier::BOLD)
} else {
Style::default().fg(Color::DarkGray)
};
let next_week_style = if active_field == 4 {
Style::default().fg(FOCUS_COLOR).add_modifier(Modifier::BOLD)
} else {
Style::default().fg(Color::DarkGray)
};
let buttons = Paragraph::new(Line::from(vec![
Span::styled(" [ Today ] ", today_style),
Span::raw(" "),
Span::styled(" [ Tomorrow ] ", tomorrow_style),
Span::raw(" "),
Span::styled(" [ Next Week ] ", next_week_style),
]))
.alignment(Alignment::Center);
frame.render_widget(buttons, rows[4]);
// ── Hint row ──
let hint = Paragraph::new(Line::from(Span::styled(
" Tab:switch field Enter:save Esc:cancel ",
Style::default().fg(Color::Gray),
)))
.alignment(Alignment::Center);
frame.render_widget(hint, rows[3]);
frame.render_widget(hint, rows[5]);
// ── Cursor ──
let (cursor_x, cursor_y) = if active_field == 0 {
(rows[0].x + 1 + title_cursor as u16, rows[0].y + 1)
} else {
(rows[2].x + 1 + notes_cursor as u16, rows[2].y + 1)
let (cursor_x, cursor_y) = match active_field {
0 => (rows[0].x + 1 + title_cursor as u16, rows[0].y + 1),
1 => (rows[2].x + 1 + notes_cursor as u16, rows[2].y + 1),
_ => return,
};
frame.set_cursor_position(ratatui::layout::Position::new(cursor_x, cursor_y));
}