refactor(ui): Simplified the popup delegation so all future UI is easier to implement

This commit is contained in:
2024-12-11 15:08:52 -07:00
parent e9a30382a3
commit c09950d0af
59 changed files with 488 additions and 660 deletions
@@ -3,12 +3,11 @@ use crate::app::App;
use crate::models::servarr_data::modals::IndexerTestResultModalItem;
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
use crate::models::Route;
use crate::ui::sonarr_ui::indexers::draw_indexers;
use crate::ui::styles::ManagarrStyle;
use crate::ui::utils::{borderless_block, get_width_from_percentage, title_block};
use crate::ui::widgets::managarr_table::ManagarrTable;
use crate::ui::widgets::popup::Size;
use crate::ui::{draw_popup_over, DrawUi};
use crate::ui::{draw_popup, DrawUi};
use ratatui::layout::{Alignment, Constraint, Rect};
use ratatui::widgets::{Cell, Row};
use ratatui::Frame;
@@ -28,12 +27,10 @@ impl DrawUi for TestAllIndexersUi {
false
}
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
draw_popup_over(
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
draw_popup(
f,
app,
area,
draw_indexers,
draw_test_all_indexers_test_results,
Size::Large,
);
@@ -41,6 +38,7 @@ impl DrawUi for TestAllIndexersUi {
}
fn draw_test_all_indexers_test_results(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
let is_loading = app.is_loading || app.data.sonarr_data.indexer_test_all_results.is_none();
let current_selection =
if let Some(test_all_results) = app.data.sonarr_data.indexer_test_all_results.as_ref() {
test_all_results.current_selection().clone()
@@ -77,7 +75,7 @@ fn draw_test_all_indexers_test_results(f: &mut Frame<'_>, app: &mut App<'_>, are
test_results_row_mapping,
)
.block(borderless_block())
.loading(app.is_loading)
.loading(is_loading)
.footer(Some(help_footer))
.footer_alignment(Alignment::Center)
.margin(1)