diff --git a/src/ui.rs b/src/ui.rs index a84bc21..294a8b5 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -28,7 +28,7 @@ pub fn render(frame: &mut Frame, app: &App) { fn render_main(frame: &mut Frame, app: &App) { // Calculate layout - accounting for bottom bar if needed - let show_bottom_bar = app.config.show_help_hint || app.config.show_command_hints; + let show_bottom_bar = app.config.show_help_hint; let has_status = app.status_message.is_some(); let bottom_height = if show_bottom_bar { if has_status { @@ -170,86 +170,22 @@ fn render_new_entry(frame: &mut Frame, app: &App) { } fn render_bottom_bar(frame: &mut Frame, area: Rect, app: &App) { - // Split the area into status and command sections if needed - let chunks = if app.status_message.is_some() { - Layout::default() - .direction(Direction::Vertical) - .constraints([ - Constraint::Length(1), // Status message - Constraint::Length(1), // Command bar - ]) - .split(area) - } else { - Layout::default() - .direction(Direction::Vertical) - .constraints([Constraint::Length(1)]) - .split(area) - }; - - let mut command_line_idx = 0; - // Render status message if present if let Some((ref message, _)) = app.status_message { let text = Paragraph::new(message.as_str()) .style(Style::default().fg(Color::Yellow)) .alignment(Alignment::Center); - frame.render_widget(text, chunks[0]); - command_line_idx = 1; + frame.render_widget(text, area); + } else if app.config.show_help_hint { + render_help_hint(frame, area); } +} - // Render command hints - if app.config.show_command_hints && chunks.len() > command_line_idx { - let commands = vec![ - ("c", "config"), - ("n", "new"), - ("p", "project"), - ("v", "log"), - ("d", "delete"), - ("q", "quit"), - ]; - - let command_text = format!( - " {}", - commands - .iter() - .map(|(key, desc)| format!("{} ({})", key, desc)) - .collect::>() - .join(" · ") - ); - - let command_area = if app.config.show_help_hint { - // Leave space for help hint - Rect::new( - chunks[command_line_idx].x, - chunks[command_line_idx].y, - chunks[command_line_idx].width.saturating_sub(12), - 1, - ) - } else { - chunks[command_line_idx] - }; - - let command_bar = Paragraph::new(command_text) - .style(Style::default().fg(Color::White)) - .alignment(Alignment::Left); - - frame.render_widget(command_bar, command_area); - } - - if app.config.show_help_hint && chunks.len() > command_line_idx { - let help_hint = Paragraph::new("(?) for help") - .alignment(Alignment::Right) - .style(Style::default().fg(Color::DarkGray)); - - let help_area = Rect::new( - chunks[command_line_idx].x + chunks[command_line_idx].width.saturating_sub(12), - chunks[command_line_idx].y, - 12, - 1, - ); - - frame.render_widget(help_hint, help_area); - } +fn render_help_hint(frame: &mut Frame, area: Rect) { + let help_hint = Paragraph::new("(?) for help") + .alignment(Alignment::Right) + .style(Style::default().fg(Color::DarkGray)); + frame.render_widget(help_hint, area); } fn render_help_command_bar(frame: &mut Frame) { @@ -559,34 +495,10 @@ fn render_log_view(frame: &mut Frame, app: &App) { let list = List::new(items).block(block); frame.render_widget(list, chunks[0]); - // Render command bar - let commands = vec![ - ("d", "day"), - ("w", "week"), - ("m", "month"), - ("g", "group"), - ("j/k", "select"), - ("e", "edit"), - ("x", "delete"), - ("c", "copy"), - ("?", "help"), - ("q/ESC", "back"), - ]; - - let command_text = format!( - " {}", - commands - .iter() - .map(|(key, desc)| format!("{} ({})", key, desc)) - .collect::>() - .join(" · ") - ); - - let command_bar = Paragraph::new(command_text) - .style(Style::default().fg(Color::White)) - .alignment(Alignment::Left); - - frame.render_widget(command_bar, chunks[1]); + // Render help hint at bottom if enabled + if app.config.show_help_hint { + render_help_hint(frame, chunks[1]); + } } fn render_log_view_help(frame: &mut Frame, _app: &App) {