tui fixed v1

This commit is contained in:
maxstrb 2025-09-24 22:38:01 +02:00
parent 3681aa2a22
commit bbee1ca79d
5 changed files with 19 additions and 4 deletions

View file

@ -165,6 +165,10 @@ impl App<'_> {
AppEvent::Reload => { AppEvent::Reload => {
self.days.reload_day_counts(db); self.days.reload_day_counts(db);
} }
AppEvent::TagEdit => {
self.switch_focus(FocusedComponent::DayPopup);
self.day_popup.tag_edit();
}
AppEvent::MonthSet(month) => { AppEvent::MonthSet(month) => {
self.days.reload(month, self.year.year, 1); self.days.reload(month, self.year.year, 1);
} }

View file

@ -215,6 +215,7 @@ impl Days {
Some(vec![AppEvent::AddEvent(start, end)]) Some(vec![AppEvent::AddEvent(start, end)])
} }
KeyCode::Char('t') => Some(vec![AppEvent::TagEdit]),
KeyCode::Down => self.handle_focused_arrows(CursorMovement::Down), KeyCode::Down => self.handle_focused_arrows(CursorMovement::Down),
KeyCode::Up => self.handle_focused_arrows(CursorMovement::Up), KeyCode::Up => self.handle_focused_arrows(CursorMovement::Up),
KeyCode::Char(' ') => { KeyCode::Char(' ') => {

View file

@ -12,6 +12,7 @@ pub enum AppEvent {
MonthScrolled(Direction), MonthScrolled(Direction),
Reload, Reload,
TagEdit,
AddEvent(NaiveDate, NaiveDate), AddEvent(NaiveDate, NaiveDate),

View file

@ -71,7 +71,7 @@ impl Focused for DayDetails {
None None
} }
KeyCode::Enter => { KeyCode::Delete => {
self.state = State::DeletionConfirm(false); self.state = State::DeletionConfirm(false);
None None
} }
@ -119,7 +119,9 @@ impl DayDetails {
if self.events.is_empty() { if self.events.is_empty() {
let outline = Block::bordered() let outline = Block::bordered()
.border_set(border::ROUNDED) .border_set(border::ROUNDED)
.border_style(Style::new().fg(Color::Blue)); .border_style(Style::new().fg(Color::Blue))
.title_alignment(Alignment::Center)
.title(" Day details - edit ");
let no_events_text = Paragraph::new("No events for this day") let no_events_text = Paragraph::new("No events for this day")
.style(Style::default().fg(Color::Red)) .style(Style::default().fg(Color::Red))
@ -133,7 +135,10 @@ impl DayDetails {
State::EventSelect => { State::EventSelect => {
let outline = Block::bordered() let outline = Block::bordered()
.border_set(border::ROUNDED) .border_set(border::ROUNDED)
.border_style(Style::new().fg(Color::Blue)); .border_style(Style::new().fg(Color::Blue))
.title(" Day details - edit ")
.title_alignment(Alignment::Center);
let layout = Layout::vertical([Constraint::Length(3), Constraint::Fill(1)]) let layout = Layout::vertical([Constraint::Length(3), Constraint::Fill(1)])
.split(outline.inner(area)); .split(outline.inner(area));
outline.render(area, buf); outline.render(area, buf);
@ -167,7 +172,7 @@ impl DayDetails {
State::DeletionConfirm(confirm) => { State::DeletionConfirm(confirm) => {
let block = Block::bordered() let block = Block::bordered()
.title(" Manage Tags ") .title(" Day details - edit ")
.title_alignment(Alignment::Center) .title_alignment(Alignment::Center)
.border_set(border::ROUNDED) .border_set(border::ROUNDED)
.border_style(Style::default().fg(Color::Blue)) .border_style(Style::default().fg(Color::Blue))

View file

@ -46,6 +46,10 @@ impl Popup<'_> {
pub fn show_day(&mut self, day: NaiveDate, events: Vec<Event>, tag_names: Vec<String>) { pub fn show_day(&mut self, day: NaiveDate, events: Vec<Event>, tag_names: Vec<String>) {
self.self_state = PopupType::DayDetails(DayDetails::show_day(day, events, tag_names)); self.self_state = PopupType::DayDetails(DayDetails::show_day(day, events, tag_names));
} }
pub fn tag_edit(&mut self) {
self.self_state = PopupType::TagManagement(TagManagement::default());
}
} }
impl Focused for Popup<'_> { impl Focused for Popup<'_> {