From 653c7274b042d01c390d44b7ceafed7e7591753d Mon Sep 17 00:00:00 2001 From: Dark-Alex-17 Date: Tue, 8 Aug 2023 10:50:07 -0600 Subject: [PATCH] Added a help block to the updates popup --- src/ui/mod.rs | 13 ++++++++++--- src/ui/radarr_ui/system_details_ui.rs | 18 +++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/ui/mod.rs b/src/ui/mod.rs index d4f0873..2a0a5df 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -323,7 +323,7 @@ fn draw_table<'a, B, T, F>( help, } = table_props; - let content_area = draw_help(f, content_area, help); + let content_area = draw_help_and_get_content_rect(f, content_area, help); if !content.items.is_empty() { let rows = content.items.iter().map(row_mapper); @@ -592,7 +592,10 @@ pub fn draw_list_box<'a, B: Backend, T>( let (content_area, block) = if is_popup { f.render_widget(title_block(title), area); - (draw_help(f, area, help), borderless_block()) + ( + draw_help_and_get_content_rect(f, area, help), + borderless_block(), + ) } else { (area, title_block(title)) }; @@ -611,7 +614,11 @@ pub fn draw_list_box<'a, B: Backend, T>( } } -fn draw_help(f: &mut Frame<'_, B>, area: Rect, help: Option<&str>) -> Rect { +fn draw_help_and_get_content_rect( + f: &mut Frame<'_, B>, + area: Rect, + help: Option<&str>, +) -> Rect { if let Some(help_string) = help { let chunks = vertical_chunks_with_margin(vec![Constraint::Min(0), Constraint::Length(2)], area, 1); diff --git a/src/ui/radarr_ui/system_details_ui.rs b/src/ui/radarr_ui/system_details_ui.rs index de7dae1..b5601e0 100644 --- a/src/ui/radarr_ui/system_details_ui.rs +++ b/src/ui/radarr_ui/system_details_ui.rs @@ -14,8 +14,8 @@ use crate::ui::radarr_ui::system_ui::{ }; use crate::ui::utils::{borderless_block, style_primary, title_block}; use crate::ui::{ - draw_help, draw_large_popup_over, draw_list_box, draw_medium_popup_over, draw_prompt_box, - draw_prompt_popup_over, draw_table, loading, DrawUi, ListProps, TableProps, + draw_help_and_get_content_rect, draw_large_popup_over, draw_list_box, draw_medium_popup_over, + draw_prompt_box, draw_prompt_popup_over, draw_table, loading, DrawUi, ListProps, TableProps, }; pub(super) struct SystemDetailsUi {} @@ -72,7 +72,7 @@ fn draw_logs_popup(f: &mut Frame<'_, B>, app: &mut App<'_>, area: Re title: "Log Details", is_loading: app.is_loading, is_popup: true, - help: Some(" close | <↑↓←→> scroll"), + help: Some("<↑↓←→> scroll | close"), }, ); } @@ -81,7 +81,8 @@ fn draw_tasks_popup(f: &mut Frame<'_, B>, app: &mut App<'_>, area: R let tasks_popup_table = |f: &mut Frame<'_, B>, app: &mut App<'_>, area: Rect| { f.render_widget(title_block("Tasks"), area); - let context_area = draw_help(f, area, Some(" start task | close")); + let context_area = + draw_help_and_get_content_rect(f, area, Some(" start task | close")); draw_table( f, @@ -135,16 +136,19 @@ fn draw_start_task_prompt(f: &mut Frame<'_, B>, app: &mut App<'_>, p } fn draw_updates_popup(f: &mut Frame<'_, B>, app: &mut App<'_>, area: Rect) { + f.render_widget(title_block("Updates"), area); + + let content_rect = draw_help_and_get_content_rect(f, area, Some("<↑↓> scroll | close")); let updates = app.data.radarr_data.updates.get_text(); - let block = title_block("Updates"); + let block = borderless_block(); if !updates.is_empty() { let updates_paragraph = Paragraph::new(Text::from(updates)) .block(block) .scroll((app.data.radarr_data.updates.offset, 0)); - f.render_widget(updates_paragraph, area); + f.render_widget(updates_paragraph, content_rect); } else { - loading(f, block, area, app.is_loading); + loading(f, block, content_rect, app.is_loading); } }