Refactored table sorting into the ManagarrTable widget and StatefulTable so any and all tables created can support sorting with minimal UI changes and thus only need to focus on the handlers. I'm going to continue this effort tomorrow and look at what other widgets can be created to simplify things. Most likely, prompt boxes.
This commit is contained in:
@@ -16,9 +16,10 @@ use crate::ui::utils::{layout_paragraph_borderless, title_block_centered};
|
||||
use crate::ui::widgets::button::Button;
|
||||
use crate::ui::widgets::checkbox::Checkbox;
|
||||
use crate::ui::widgets::input_box::InputBox;
|
||||
use crate::ui::widgets::popup::Popup;
|
||||
use crate::ui::widgets::selectable_list::SelectableList;
|
||||
use crate::ui::{
|
||||
draw_drop_down_popup, draw_large_popup_over_background_fn_with_ui, draw_medium_popup_over,
|
||||
draw_popup, draw_selectable_list, DrawUi,
|
||||
draw_large_popup_over_background_fn_with_ui, draw_medium_popup_over, draw_popup, DrawUi,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -41,22 +42,12 @@ impl DrawUi for EditCollectionUi {
|
||||
let draw_edit_collection_prompt =
|
||||
|f: &mut Frame<'_>, app: &mut App<'_>, prompt_area: Rect| match active_radarr_block {
|
||||
ActiveRadarrBlock::EditCollectionSelectMinimumAvailability => {
|
||||
draw_drop_down_popup(
|
||||
f,
|
||||
app,
|
||||
prompt_area,
|
||||
draw_edit_collection_confirmation_prompt,
|
||||
draw_edit_collection_select_minimum_availability_popup,
|
||||
);
|
||||
draw_edit_collection_confirmation_prompt(f, app, prompt_area);
|
||||
draw_edit_collection_select_minimum_availability_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::EditCollectionSelectQualityProfile => {
|
||||
draw_drop_down_popup(
|
||||
f,
|
||||
app,
|
||||
prompt_area,
|
||||
draw_edit_collection_confirmation_prompt,
|
||||
draw_edit_collection_select_quality_profile_popup,
|
||||
);
|
||||
draw_edit_collection_confirmation_prompt(f, app, prompt_area);
|
||||
draw_edit_collection_select_quality_profile_popup(f, app);
|
||||
}
|
||||
ActiveRadarrBlock::EditCollectionPrompt
|
||||
| ActiveRadarrBlock::EditCollectionToggleMonitored
|
||||
@@ -180,14 +171,8 @@ fn draw_edit_collection_confirmation_prompt(f: &mut Frame<'_>, app: &mut App<'_>
|
||||
f.render_widget(cancel_button, cancel_area);
|
||||
}
|
||||
|
||||
fn draw_edit_collection_select_minimum_availability_popup(
|
||||
f: &mut Frame<'_>,
|
||||
app: &mut App<'_>,
|
||||
area: Rect,
|
||||
) {
|
||||
draw_selectable_list(
|
||||
f,
|
||||
area,
|
||||
fn draw_edit_collection_select_minimum_availability_popup(f: &mut Frame<'_>, app: &mut App<'_>) {
|
||||
let min_availability_list = SelectableList::new(
|
||||
&mut app
|
||||
.data
|
||||
.radarr_data
|
||||
@@ -197,16 +182,16 @@ fn draw_edit_collection_select_minimum_availability_popup(
|
||||
.minimum_availability_list,
|
||||
|minimum_availability| ListItem::new(minimum_availability.to_display_str().to_owned()),
|
||||
);
|
||||
let popup = Popup::new(min_availability_list, 20, 30);
|
||||
|
||||
f.render_widget(popup, f.size());
|
||||
}
|
||||
|
||||
fn draw_edit_collection_select_quality_profile_popup(
|
||||
f: &mut Frame<'_>,
|
||||
app: &mut App<'_>,
|
||||
area: Rect,
|
||||
) {
|
||||
draw_selectable_list(
|
||||
f,
|
||||
area,
|
||||
let quality_profile_list = SelectableList::new(
|
||||
&mut app
|
||||
.data
|
||||
.radarr_data
|
||||
@@ -216,4 +201,7 @@ fn draw_edit_collection_select_quality_profile_popup(
|
||||
.quality_profile_list,
|
||||
|quality_profile| ListItem::new(quality_profile.clone()),
|
||||
);
|
||||
let popup = Popup::new(quality_profile_list, 20, 30);
|
||||
|
||||
f.render_widget(popup, f.size());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user