Refactored all popups to use centrally defined, consistent sizes.
This commit is contained in:
@@ -20,9 +20,9 @@ use crate::ui::widgets::button::Button;
|
||||
use crate::ui::widgets::error_message::ErrorMessage;
|
||||
use crate::ui::widgets::input_box::InputBox;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::Popup;
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::widgets::selectable_list::SelectableList;
|
||||
use crate::ui::{draw_large_popup_over, draw_medium_popup_over, DrawUi};
|
||||
use crate::ui::{draw_popup_over, DrawUi};
|
||||
use crate::utils::convert_runtime;
|
||||
use crate::{render_selectable_input_box, App};
|
||||
|
||||
@@ -57,25 +57,30 @@ impl DrawUi for AddMovieUi {
|
||||
| ActiveRadarrBlock::AddMovieSelectRootFolder
|
||||
| ActiveRadarrBlock::AddMovieTagsInput => {
|
||||
if context_option.is_some() {
|
||||
draw_medium_popup_over(
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_collection_details,
|
||||
draw_confirmation_popup,
|
||||
Size::Medium,
|
||||
);
|
||||
} else {
|
||||
draw_medium_popup_over(f, app, area, draw_add_movie_search, draw_confirmation_popup);
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_add_movie_search,
|
||||
draw_confirmation_popup,
|
||||
Size::Medium,
|
||||
);
|
||||
}
|
||||
}
|
||||
ActiveRadarrBlock::AddMovieAlreadyInLibrary => {
|
||||
draw_add_movie_search(f, app, area);
|
||||
f.render_widget(
|
||||
Popup::new(
|
||||
ErrorMessage::new("This film is already in your library"),
|
||||
25,
|
||||
8,
|
||||
),
|
||||
Popup::new(ErrorMessage::new("This film is already in your library"))
|
||||
.size(Size::Error),
|
||||
f.size(),
|
||||
);
|
||||
}
|
||||
@@ -85,9 +90,23 @@ impl DrawUi for AddMovieUi {
|
||||
match active_radarr_block {
|
||||
_ if ADD_MOVIE_BLOCKS.contains(&active_radarr_block) => {
|
||||
if context_option.is_some() {
|
||||
draw_large_popup_over(f, app, area, draw_collections, draw_add_movie_search_popup)
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_collections,
|
||||
draw_add_movie_search_popup,
|
||||
Size::Large,
|
||||
)
|
||||
} else {
|
||||
draw_large_popup_over(f, app, area, draw_library, draw_add_movie_search_popup)
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_library,
|
||||
draw_add_movie_search_popup,
|
||||
Size::Large,
|
||||
)
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
@@ -202,7 +221,7 @@ fn draw_add_movie_search(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
.block(borderless_block())
|
||||
.alignment(Alignment::Center);
|
||||
let error_message = ErrorMessage::new("No movies found matching your query!");
|
||||
let error_message_popup = Popup::new(error_message, 25, 8);
|
||||
let error_message_popup = Popup::new(error_message).size(Size::Error);
|
||||
|
||||
f.render_widget(layout_block(), results_area);
|
||||
f.render_widget(error_message_popup, f.size());
|
||||
@@ -427,7 +446,7 @@ fn draw_add_movie_select_monitor_popup(f: &mut Frame<'_>, app: &mut App<'_>) {
|
||||
.monitor_list,
|
||||
|monitor| ListItem::new(monitor.to_display_str().to_owned()),
|
||||
);
|
||||
let popup = Popup::new(monitor_list, 20, 30);
|
||||
let popup = Popup::new(monitor_list).size(Size::Dropdown);
|
||||
|
||||
f.render_widget(popup, f.size());
|
||||
}
|
||||
@@ -443,7 +462,7 @@ fn draw_add_movie_select_minimum_availability_popup(f: &mut Frame<'_>, app: &mut
|
||||
.minimum_availability_list,
|
||||
|minimum_availability| ListItem::new(minimum_availability.to_display_str().to_owned()),
|
||||
);
|
||||
let popup = Popup::new(minimum_availability_list, 20, 30);
|
||||
let popup = Popup::new(minimum_availability_list).size(Size::Dropdown);
|
||||
|
||||
f.render_widget(popup, f.size());
|
||||
}
|
||||
@@ -459,7 +478,7 @@ fn draw_add_movie_select_quality_profile_popup(f: &mut Frame<'_>, app: &mut App<
|
||||
.quality_profile_list,
|
||||
|quality_profile| ListItem::new(quality_profile.clone()),
|
||||
);
|
||||
let popup = Popup::new(quality_profile_list, 20, 30);
|
||||
let popup = Popup::new(quality_profile_list).size(Size::Dropdown);
|
||||
|
||||
f.render_widget(popup, f.size());
|
||||
}
|
||||
@@ -475,7 +494,7 @@ fn draw_add_movie_select_root_folder_popup(f: &mut Frame<'_>, app: &mut App<'_>)
|
||||
.root_folder_list,
|
||||
|root_folder| ListItem::new(root_folder.path.to_owned()),
|
||||
);
|
||||
let popup = Popup::new(root_folder_list, 20, 30);
|
||||
let popup = Popup::new(root_folder_list).size(Size::Dropdown);
|
||||
|
||||
f.render_widget(popup, f.size());
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ use crate::app::App;
|
||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, DELETE_MOVIE_BLOCKS};
|
||||
use crate::models::Route;
|
||||
use crate::ui::radarr_ui::library::draw_library;
|
||||
use crate::ui::{draw_prompt_box_with_checkboxes, draw_prompt_popup_over, DrawUi};
|
||||
use crate::ui::widgets::popup::Size;
|
||||
use crate::ui::{draw_popup_over, draw_prompt_box_with_checkboxes, DrawUi};
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "delete_movie_ui_tests.rs"]
|
||||
@@ -55,7 +56,14 @@ impl DrawUi for DeleteMovieUi {
|
||||
)
|
||||
};
|
||||
|
||||
draw_prompt_popup_over(f, app, area, draw_library, draw_delete_movie_prompt);
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_library,
|
||||
draw_delete_movie_prompt,
|
||||
Size::Prompt,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,9 @@ 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::popup::{Popup, Size};
|
||||
use crate::ui::widgets::selectable_list::SelectableList;
|
||||
use crate::ui::{
|
||||
draw_large_popup_over_background_fn_with_ui, draw_medium_popup_over, draw_popup, DrawUi,
|
||||
};
|
||||
use crate::ui::{draw_popup, draw_popup_over, draw_popup_over_ui, DrawUi};
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "edit_movie_ui_tests.rs"]
|
||||
@@ -63,16 +61,18 @@ impl DrawUi for EditMovieUi {
|
||||
if let Some(context) = context_option {
|
||||
match context {
|
||||
ActiveRadarrBlock::Movies => {
|
||||
draw_medium_popup_over(f, app, area, draw_library, draw_edit_movie_prompt);
|
||||
}
|
||||
_ if MOVIE_DETAILS_BLOCKS.contains(&context) => {
|
||||
draw_large_popup_over_background_fn_with_ui::<MovieDetailsUi>(
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_library,
|
||||
draw_edit_movie_prompt,
|
||||
Size::Medium,
|
||||
);
|
||||
draw_popup(f, app, draw_edit_movie_prompt, 60, 60);
|
||||
}
|
||||
_ if MOVIE_DETAILS_BLOCKS.contains(&context) => {
|
||||
draw_popup_over_ui::<MovieDetailsUi>(f, app, area, draw_library, Size::Large);
|
||||
draw_popup(f, app, draw_edit_movie_prompt, Size::Medium);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
@@ -192,7 +192,7 @@ fn draw_edit_movie_select_minimum_availability_popup(f: &mut Frame<'_>, app: &mu
|
||||
.minimum_availability_list,
|
||||
|minimum_availability| ListItem::new(minimum_availability.to_display_str().to_owned()),
|
||||
);
|
||||
let popup = Popup::new(minimum_availability_list, 20, 30);
|
||||
let popup = Popup::new(minimum_availability_list).size(Size::Dropdown);
|
||||
|
||||
f.render_widget(popup, f.size());
|
||||
}
|
||||
@@ -208,7 +208,7 @@ fn draw_edit_movie_select_quality_profile_popup(f: &mut Frame<'_>, app: &mut App
|
||||
.quality_profile_list,
|
||||
|quality_profile| ListItem::new(quality_profile.clone()),
|
||||
);
|
||||
let popup = Popup::new(quality_profile_list, 20, 30);
|
||||
let popup = Popup::new(quality_profile_list).size(Size::Dropdown);
|
||||
|
||||
f.render_widget(popup, f.size());
|
||||
}
|
||||
|
||||
@@ -14,9 +14,8 @@ use crate::ui::radarr_ui::library::movie_details_ui::MovieDetailsUi;
|
||||
use crate::ui::utils::{get_width_from_percentage, layout_block_top_border};
|
||||
use crate::ui::widgets::error_message::ErrorMessage;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::{
|
||||
draw_input_box_popup, draw_popup_over, draw_prompt_box, draw_prompt_popup_over, DrawUi,
|
||||
};
|
||||
use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::{draw_input_box_popup, draw_popup_over, draw_prompt_box, DrawUi};
|
||||
use crate::utils::{convert_runtime, convert_to_gb};
|
||||
|
||||
mod add_movie_ui;
|
||||
@@ -48,33 +47,43 @@ impl DrawUi for LibraryUi {
|
||||
let mut library_ui_matchers = |active_radarr_block: ActiveRadarrBlock| match active_radarr_block
|
||||
{
|
||||
ActiveRadarrBlock::Movies => draw_library(f, app, area),
|
||||
ActiveRadarrBlock::SearchMovie => {
|
||||
draw_popup_over(f, app, area, draw_library, draw_movie_search_box, 30, 13)
|
||||
}
|
||||
ActiveRadarrBlock::SearchMovieError => draw_popup_over(
|
||||
ActiveRadarrBlock::SearchMovie => draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_library,
|
||||
draw_search_movie_error_box,
|
||||
30,
|
||||
8,
|
||||
draw_movie_search_box,
|
||||
Size::InputBox,
|
||||
),
|
||||
ActiveRadarrBlock::FilterMovies => {
|
||||
draw_popup_over(f, app, area, draw_library, draw_filter_movies_box, 30, 13)
|
||||
ActiveRadarrBlock::SearchMovieError => {
|
||||
draw_library(f, app, area);
|
||||
let popup = Popup::new(ErrorMessage::new("Movie not found!")).size(Size::Error);
|
||||
f.render_widget(popup, f.size());
|
||||
}
|
||||
ActiveRadarrBlock::FilterMoviesError => draw_popup_over(
|
||||
ActiveRadarrBlock::FilterMovies => draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_library,
|
||||
draw_filter_movies_error_box,
|
||||
30,
|
||||
8,
|
||||
draw_filter_movies_box,
|
||||
Size::InputBox,
|
||||
),
|
||||
ActiveRadarrBlock::UpdateAllMoviesPrompt => {
|
||||
draw_prompt_popup_over(f, app, area, draw_library, draw_update_all_movies_prompt)
|
||||
ActiveRadarrBlock::FilterMoviesError => {
|
||||
draw_library(f, app, area);
|
||||
let popup = Popup::new(ErrorMessage::new(
|
||||
"No movies found matching the given filter!",
|
||||
))
|
||||
.size(Size::Error);
|
||||
f.render_widget(popup, f.size());
|
||||
}
|
||||
ActiveRadarrBlock::UpdateAllMoviesPrompt => draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_library,
|
||||
draw_update_all_movies_prompt,
|
||||
Size::Prompt,
|
||||
),
|
||||
_ => (),
|
||||
};
|
||||
|
||||
@@ -209,14 +218,3 @@ fn draw_filter_movies_box(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
app.data.radarr_data.movies.filter.as_ref().unwrap(),
|
||||
)
|
||||
}
|
||||
|
||||
fn draw_search_movie_error_box(f: &mut Frame<'_>, _: &mut App<'_>, area: Rect) {
|
||||
f.render_widget(ErrorMessage::new("Movie not found!"), area);
|
||||
}
|
||||
|
||||
fn draw_filter_movies_error_box(f: &mut Frame<'_>, _: &mut App<'_>, area: Rect) {
|
||||
f.render_widget(
|
||||
ErrorMessage::new("No movies found matching the given filter!"),
|
||||
area,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ use crate::ui::utils::{
|
||||
};
|
||||
use crate::ui::widgets::loading_block::LoadingBlock;
|
||||
use crate::ui::widgets::managarr_table::ManagarrTable;
|
||||
use crate::ui::widgets::popup::Size;
|
||||
use crate::ui::{
|
||||
draw_large_popup_over, draw_prompt_box, draw_prompt_box_with_content, draw_prompt_popup_over,
|
||||
draw_small_popup_over, draw_tabs, DrawUi,
|
||||
draw_popup_over, draw_prompt_box, draw_prompt_box_with_content, draw_tabs, DrawUi,
|
||||
};
|
||||
use crate::utils::convert_to_gb;
|
||||
|
||||
@@ -49,32 +49,42 @@ impl DrawUi for MovieDetailsUi {
|
||||
);
|
||||
|
||||
match context_option.unwrap_or(active_radarr_block) {
|
||||
ActiveRadarrBlock::AutomaticallySearchMoviePrompt => draw_prompt_popup_over(
|
||||
ActiveRadarrBlock::AutomaticallySearchMoviePrompt => draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
content_area,
|
||||
draw_movie_info,
|
||||
draw_search_movie_prompt,
|
||||
Size::Prompt,
|
||||
),
|
||||
ActiveRadarrBlock::UpdateAndScanPrompt => draw_prompt_popup_over(
|
||||
ActiveRadarrBlock::UpdateAndScanPrompt => draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
content_area,
|
||||
draw_movie_info,
|
||||
draw_update_and_scan_prompt,
|
||||
Size::Prompt,
|
||||
),
|
||||
ActiveRadarrBlock::ManualSearchConfirmPrompt => draw_small_popup_over(
|
||||
ActiveRadarrBlock::ManualSearchConfirmPrompt => draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
content_area,
|
||||
draw_movie_info,
|
||||
draw_manual_search_confirm_prompt,
|
||||
Size::Small,
|
||||
),
|
||||
_ => draw_movie_info(f, app, content_area),
|
||||
}
|
||||
};
|
||||
|
||||
draw_large_popup_over(f, app, area, draw_library, draw_movie_info_popup);
|
||||
draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
area,
|
||||
draw_library,
|
||||
draw_movie_info_popup,
|
||||
Size::Large,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user