From 05f885f38db531f203f47bc985ed723f783df6b8 Mon Sep 17 00:00:00 2001 From: itsscb Date: Fri, 25 Jul 2025 15:51:01 +0200 Subject: [PATCH] feat: add hints to blocks and update colors --- src/lib.rs | 65 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5134c4c..7edd00a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -91,8 +91,30 @@ impl App { fn draw(&mut self, frame: &mut Frame) { self.render(frame.area(), frame.buffer_mut()); if let Some(ref item) = self.edit { - let block = Block::bordered().title("Details"); - let area = popup_area(frame.area(), 80, 80); + let block = Block::bordered() + .title(Span::styled( + "Details", + Style::default().bold().fg(COLOR_SECONDARY), + )) + .title_bottom(Line::from(vec![ + Span::raw(" Save "), + Span::styled( + " | ", + Style::default() + .fg(COLOR_SECONDARY) + .add_modifier(Modifier::BOLD), + ), + Span::raw(" Cancel "), + Span::styled( + " | ", + Style::default() + .fg(COLOR_SECONDARY) + .add_modifier(Modifier::BOLD), + ), + ])) + .title_style(Style::default().bold().fg(Color::White)); + + let area = popup_area(frame.area(), 90, 90); frame.render_widget(Clear, area); @@ -112,6 +134,7 @@ impl App { "modified at {}", item.modified().format("%Y-%m-%d %H:%M:%S").to_string() )) + .style(Style::default().fg(COLOR_SECONDARY).bold()) .right_aligned(), ) .right_aligned(), @@ -119,10 +142,13 @@ impl App { ); frame.render_widget( - Paragraph::new(Text::from(format!( - "created at {}", - item.created().format("%Y-%m-%d %H:%M:%S").to_string() - ))), + Paragraph::new( + Text::from(format!( + "created at {}", + item.created().format("%Y-%m-%d %H:%M:%S").to_string() + )) + .style(Style::default().fg(COLOR_SECONDARY).bold()), + ), inner[0], ); @@ -161,6 +187,7 @@ impl App { self.update(item.id(), item.content()); } else { self.logs.push(item.clone()); + self.logs.sort_by(|a, b| b.created().cmp(&a.created())); } self.edit = None; self.save()?; @@ -319,35 +346,49 @@ impl Widget for &mut App { let instructions = Line::from(vec![ Span::raw(" New "), Span::styled( - "", + "", Style::default() .fg(COLOR_PRIMARY) .add_modifier(Modifier::BOLD), ), Span::raw(" Select "), Span::styled( - "", + " | | ", Style::default() .fg(COLOR_PRIMARY) .add_modifier(Modifier::BOLD), ), Span::raw(" Down "), Span::styled( - "", + "", Style::default() .fg(COLOR_PRIMARY) .add_modifier(Modifier::BOLD), ), Span::raw(" Up "), Span::styled( - "", + "", + Style::default() + .fg(COLOR_PRIMARY) + .add_modifier(Modifier::BOLD), + ), + Span::raw(" Bottom "), + Span::styled( + "", + Style::default() + .fg(COLOR_PRIMARY) + .add_modifier(Modifier::BOLD), + ), + Span::raw(" Top "), + Span::styled( + "", Style::default() .fg(COLOR_PRIMARY) .add_modifier(Modifier::BOLD), ), Span::raw(" Quit "), Span::styled( - " | ", + " | ", Style::default() .fg(COLOR_PRIMARY) .add_modifier(Modifier::BOLD), @@ -400,7 +441,7 @@ impl Widget for &mut App { }) .collect::() .style(Style::new().fg(Color::White)) - .height(4) + .height(2) }) .collect();