Completed edit movies implementation, cleaned up the Movies table, and fixed a bug when adding a movie from the CollectionDetails screen.
This commit is contained in:
+115
-7
@@ -15,8 +15,8 @@ use crate::models::{Route, StatefulList, StatefulTable, TabState};
|
||||
use crate::ui::utils::{
|
||||
borderless_block, centered_rect, horizontal_chunks, horizontal_chunks_with_margin, layout_block,
|
||||
layout_block_top_border, layout_button_paragraph, layout_button_paragraph_borderless,
|
||||
layout_paragraph_borderless, logo_block, style_button_highlight, style_default_bold,
|
||||
style_failure, style_help, style_highlight, style_primary, style_secondary,
|
||||
layout_paragraph_borderless, logo_block, show_cursor, style_block_highlight, style_default,
|
||||
style_default_bold, style_failure, style_help, style_highlight, style_primary, style_secondary,
|
||||
style_system_function, title_block, title_block_centered, vertical_chunks,
|
||||
vertical_chunks_with_margin,
|
||||
};
|
||||
@@ -57,7 +57,7 @@ pub fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
|
||||
draw_header_row(f, app, main_chunks[0]);
|
||||
draw_context_row(f, app, main_chunks[1]);
|
||||
if let Route::Radarr(_, _) = app.get_current_route() {
|
||||
radarr_ui::draw_radarr_ui(f, app, main_chunks[2])
|
||||
radarr_ui::draw_radarr_ui(f, app, main_chunks[2]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,18 @@ fn draw_error<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
|
||||
f.render_widget(paragraph, area);
|
||||
}
|
||||
|
||||
pub fn draw_popup<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
app: &mut App,
|
||||
popup_fn: fn(&mut Frame<'_, B>, &mut App, Rect),
|
||||
percent_x: u16,
|
||||
percent_y: u16,
|
||||
) {
|
||||
let popup_area = centered_rect(percent_x, percent_y, f.size());
|
||||
f.render_widget(Clear, popup_area);
|
||||
popup_fn(f, app, popup_area);
|
||||
}
|
||||
|
||||
pub fn draw_popup_over<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
app: &mut App,
|
||||
@@ -117,9 +129,7 @@ pub fn draw_popup_over<B: Backend>(
|
||||
) {
|
||||
background_fn(f, app, area);
|
||||
|
||||
let popup_area = centered_rect(percent_x, percent_y, f.size());
|
||||
f.render_widget(Clear, popup_area);
|
||||
popup_fn(f, app, popup_area);
|
||||
draw_popup(f, app, popup_fn, percent_x, percent_y);
|
||||
}
|
||||
|
||||
pub fn draw_prompt_popup_over<B: Backend>(
|
||||
@@ -375,6 +385,44 @@ pub fn draw_prompt_box_with_content<B: Backend>(
|
||||
draw_button(f, horizontal_chunks[1], "No", !*yes_no_value);
|
||||
}
|
||||
|
||||
pub fn draw_checkbox<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
area: Rect,
|
||||
is_checked: bool,
|
||||
is_selected: bool,
|
||||
) {
|
||||
let check = if is_checked { "✔" } else { "" };
|
||||
let label_paragraph = Paragraph::new(Text::from(check))
|
||||
.block(layout_block())
|
||||
.alignment(Alignment::Center)
|
||||
.style(style_block_highlight(is_selected).add_modifier(Modifier::BOLD));
|
||||
let checkbox_area = Rect { width: 5, ..area };
|
||||
|
||||
f.render_widget(label_paragraph, checkbox_area);
|
||||
}
|
||||
|
||||
pub fn draw_checkbox_with_label<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
area: Rect,
|
||||
label: &str,
|
||||
is_checked: bool,
|
||||
is_selected: bool,
|
||||
) {
|
||||
let horizontal_chunks = horizontal_chunks(
|
||||
vec![Constraint::Percentage(50), Constraint::Percentage(50)],
|
||||
area,
|
||||
);
|
||||
|
||||
let label_paragraph = Paragraph::new(Text::from(format!("\n{}: ", label)))
|
||||
.block(borderless_block())
|
||||
.alignment(Alignment::Right)
|
||||
.style(style_primary());
|
||||
|
||||
f.render_widget(label_paragraph, horizontal_chunks[0]);
|
||||
|
||||
draw_checkbox(f, horizontal_chunks[1], is_checked, is_selected);
|
||||
}
|
||||
|
||||
pub fn draw_button<B: Backend>(f: &mut Frame<'_, B>, area: Rect, label: &str, is_selected: bool) {
|
||||
let label_paragraph = layout_button_paragraph(is_selected, label, Alignment::Center);
|
||||
|
||||
@@ -398,7 +446,7 @@ pub fn draw_button_with_icon<B: Backend>(
|
||||
);
|
||||
|
||||
f.render_widget(
|
||||
layout_block().style(style_button_highlight(is_selected)),
|
||||
layout_block().style(style_block_highlight(is_selected)),
|
||||
area,
|
||||
);
|
||||
f.render_widget(label_paragraph, horizontal_chunks[0]);
|
||||
@@ -440,3 +488,63 @@ pub fn draw_drop_down_list<'a, B: Backend, T>(
|
||||
|
||||
f.render_stateful_widget(list, area, &mut content.state);
|
||||
}
|
||||
|
||||
pub fn draw_text_box<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
text_box_area: Rect,
|
||||
block_title: Option<&str>,
|
||||
block_content: &str,
|
||||
should_show_cursor: bool,
|
||||
is_selected: bool,
|
||||
) {
|
||||
let (block, style) = if let Some(..) = block_title {
|
||||
(title_block_centered(block_title.unwrap()), style_default())
|
||||
} else {
|
||||
(
|
||||
layout_block(),
|
||||
if should_show_cursor {
|
||||
style_default()
|
||||
} else {
|
||||
style_block_highlight(is_selected)
|
||||
},
|
||||
)
|
||||
};
|
||||
let search_paragraph = Paragraph::new(Text::from(block_content))
|
||||
.style(style)
|
||||
.block(block);
|
||||
f.render_widget(search_paragraph, text_box_area);
|
||||
|
||||
if should_show_cursor {
|
||||
show_cursor(f, text_box_area, block_content);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw_text_box_with_label<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
area: Rect,
|
||||
label: &str,
|
||||
text: &str,
|
||||
is_selected: bool,
|
||||
should_show_cursor: bool,
|
||||
) {
|
||||
let horizontal_chunks = horizontal_chunks(
|
||||
vec![Constraint::Percentage(50), Constraint::Percentage(50)],
|
||||
area,
|
||||
);
|
||||
|
||||
let label_paragraph = Paragraph::new(Text::from(format!("\n{}: ", label)))
|
||||
.block(borderless_block())
|
||||
.alignment(Alignment::Right)
|
||||
.style(style_primary());
|
||||
|
||||
f.render_widget(label_paragraph, horizontal_chunks[0]);
|
||||
|
||||
draw_text_box(
|
||||
f,
|
||||
horizontal_chunks[1],
|
||||
None,
|
||||
text,
|
||||
should_show_cursor,
|
||||
is_selected,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,14 +8,18 @@ use crate::app::radarr::ActiveRadarrBlock;
|
||||
use crate::models::radarr_models::AddMovieSearchResult;
|
||||
use crate::models::Route;
|
||||
use crate::ui::radarr_ui::collection_details_ui::draw_collection_details;
|
||||
use crate::ui::radarr_ui::{
|
||||
draw_select_minimum_availability_popup, draw_select_quality_profile_popup,
|
||||
};
|
||||
use crate::ui::utils::{
|
||||
borderless_block, get_width_from_percentage, horizontal_chunks, layout_block,
|
||||
layout_paragraph_borderless, show_cursor, style_default, style_help, style_primary,
|
||||
title_block_centered, vertical_chunks_with_margin,
|
||||
layout_paragraph_borderless, style_help, style_primary, title_block_centered,
|
||||
vertical_chunks_with_margin,
|
||||
};
|
||||
use crate::ui::{
|
||||
draw_button, draw_drop_down_list, draw_drop_down_menu_button, draw_drop_down_popup,
|
||||
draw_error_popup, draw_error_popup_over, draw_medium_popup_over, draw_table, TableProps,
|
||||
draw_error_popup, draw_error_popup_over, draw_medium_popup_over, draw_table, draw_text_box,
|
||||
TableProps,
|
||||
};
|
||||
use crate::utils::convert_runtime;
|
||||
use crate::App;
|
||||
@@ -80,14 +84,10 @@ fn draw_add_movie_search<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area:
|
||||
);
|
||||
let block_content = app.data.radarr_data.search.as_str();
|
||||
|
||||
let search_paragraph = Paragraph::new(Text::from(block_content))
|
||||
.style(style_default())
|
||||
.block(title_block_centered("Add Movie"));
|
||||
|
||||
if let Route::Radarr(active_radarr_block, _) = *app.get_current_route() {
|
||||
match active_radarr_block {
|
||||
ActiveRadarrBlock::AddMovieSearchInput => {
|
||||
show_cursor(f, chunks[0], block_content);
|
||||
draw_text_box(f, chunks[0], Some("Add Movie"), block_content, true, false);
|
||||
f.render_widget(layout_block(), chunks[1]);
|
||||
|
||||
let mut help_text = Text::from("<esc> close");
|
||||
@@ -124,7 +124,7 @@ fn draw_add_movie_search<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area:
|
||||
TableProps {
|
||||
content: &mut app.data.radarr_data.add_searched_movies,
|
||||
table_headers: vec![
|
||||
"✓",
|
||||
"✔",
|
||||
"Title",
|
||||
"Year",
|
||||
"Runtime",
|
||||
@@ -179,7 +179,7 @@ fn draw_add_movie_search<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area:
|
||||
.iter()
|
||||
.any(|mov| mov.tmdb_id == movie.tmdb_id)
|
||||
{
|
||||
"✓"
|
||||
"✔"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
@@ -208,7 +208,7 @@ fn draw_add_movie_search<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area:
|
||||
}
|
||||
}
|
||||
|
||||
f.render_widget(search_paragraph, chunks[0]);
|
||||
draw_text_box(f, chunks[0], Some("Add Movie"), block_content, false, false);
|
||||
}
|
||||
|
||||
fn draw_confirmation_popup<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, prompt_area: Rect) {
|
||||
@@ -251,37 +251,11 @@ fn draw_select_monitor_popup<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, po
|
||||
draw_drop_down_list(
|
||||
f,
|
||||
popup_area,
|
||||
&mut app.data.radarr_data.add_movie_monitor_list,
|
||||
&mut app.data.radarr_data.movie_monitor_list,
|
||||
|monitor| ListItem::new(monitor.to_display_str().to_owned()),
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_select_minimum_availability_popup<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
app: &mut App,
|
||||
popup_area: Rect,
|
||||
) {
|
||||
draw_drop_down_list(
|
||||
f,
|
||||
popup_area,
|
||||
&mut app.data.radarr_data.add_movie_minimum_availability_list,
|
||||
|minimum_availability| ListItem::new(minimum_availability.to_display_str().to_owned()),
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_select_quality_profile_popup<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
app: &mut App,
|
||||
popup_area: Rect,
|
||||
) {
|
||||
draw_drop_down_list(
|
||||
f,
|
||||
popup_area,
|
||||
&mut app.data.radarr_data.add_movie_quality_profile_list,
|
||||
|quality_profile| ListItem::new(quality_profile.clone()),
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_confirmation_prompt<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, prompt_area: Rect) {
|
||||
let title = "Add Movie";
|
||||
let (movie_title, movie_overview) = if let Route::Radarr(_, Some(_)) = app.get_current_route() {
|
||||
@@ -292,7 +266,7 @@ fn draw_confirmation_prompt<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, pro
|
||||
.collection_movies
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
.stationary_style(),
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
@@ -324,20 +298,16 @@ fn draw_confirmation_prompt<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, pro
|
||||
let selected_block = &app.data.radarr_data.selected_block;
|
||||
let highlight_yes_no = *selected_block == ActiveRadarrBlock::AddMovieConfirmPrompt;
|
||||
|
||||
let selected_monitor = app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_movie_monitor_list
|
||||
.current_selection();
|
||||
let selected_monitor = app.data.radarr_data.movie_monitor_list.current_selection();
|
||||
let selected_minimum_availability = app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_movie_minimum_availability_list
|
||||
.movie_minimum_availability_list
|
||||
.current_selection();
|
||||
let selected_quality_profile = app
|
||||
.data
|
||||
.radarr_data
|
||||
.add_movie_quality_profile_list
|
||||
.movie_quality_profile_list
|
||||
.current_selection();
|
||||
|
||||
f.render_widget(title_block_centered(title), prompt_area);
|
||||
|
||||
@@ -119,7 +119,7 @@ pub(super) fn draw_collection_details<B: Backend>(
|
||||
TableProps {
|
||||
content: &mut app.data.radarr_data.collection_movies,
|
||||
table_headers: vec![
|
||||
"✓",
|
||||
"✔",
|
||||
"Title",
|
||||
"Year",
|
||||
"Runtime",
|
||||
@@ -147,7 +147,7 @@ pub(super) fn draw_collection_details<B: Backend>(
|
||||
.iter()
|
||||
.any(|mov| mov.tmdb_id == movie.tmdb_id)
|
||||
{
|
||||
"✓"
|
||||
"✔"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
use tui::backend::Backend;
|
||||
use tui::layout::{Constraint, Rect};
|
||||
use tui::Frame;
|
||||
|
||||
use crate::app::radarr::ActiveRadarrBlock;
|
||||
use crate::app::App;
|
||||
use crate::models::Route;
|
||||
use crate::ui::radarr_ui::{
|
||||
draw_select_minimum_availability_popup, draw_select_quality_profile_popup,
|
||||
};
|
||||
use crate::ui::utils::{
|
||||
horizontal_chunks, layout_paragraph_borderless, title_block_centered, vertical_chunks_with_margin,
|
||||
};
|
||||
use crate::ui::{
|
||||
draw_button, draw_checkbox_with_label, draw_drop_down_menu_button, draw_drop_down_popup,
|
||||
draw_text_box_with_label,
|
||||
};
|
||||
|
||||
pub(super) fn draw_edit_movie_prompt<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
app: &mut App,
|
||||
prompt_area: Rect,
|
||||
) {
|
||||
if let Route::Radarr(active_radarr_block, _) = *app.get_current_route() {
|
||||
match active_radarr_block {
|
||||
ActiveRadarrBlock::EditMovieSelectMinimumAvailability => {
|
||||
draw_drop_down_popup(
|
||||
f,
|
||||
app,
|
||||
prompt_area,
|
||||
draw_edit_confirmation_prompt,
|
||||
draw_select_minimum_availability_popup,
|
||||
);
|
||||
}
|
||||
ActiveRadarrBlock::EditMovieSelectQualityProfile => {
|
||||
draw_drop_down_popup(
|
||||
f,
|
||||
app,
|
||||
prompt_area,
|
||||
draw_edit_confirmation_prompt,
|
||||
draw_select_quality_profile_popup,
|
||||
);
|
||||
}
|
||||
ActiveRadarrBlock::EditMoviePrompt
|
||||
| ActiveRadarrBlock::EditMovieToggleMonitored
|
||||
| ActiveRadarrBlock::EditMoviePathInput
|
||||
| ActiveRadarrBlock::EditMovieTagsInput => draw_edit_confirmation_prompt(f, app, prompt_area),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_edit_confirmation_prompt<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
app: &mut App,
|
||||
prompt_area: Rect,
|
||||
) {
|
||||
let (movie_title, movie_overview) = (
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.movies
|
||||
.current_selection()
|
||||
.title
|
||||
.to_string(),
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.movies
|
||||
.current_selection()
|
||||
.overview
|
||||
.clone(),
|
||||
);
|
||||
let title = format!("Edit - {}", movie_title);
|
||||
let yes_no_value = &app.data.radarr_data.prompt_confirm;
|
||||
let selected_block = &app.data.radarr_data.selected_block;
|
||||
let highlight_yes_no = *selected_block == ActiveRadarrBlock::EditMovieConfirmPrompt;
|
||||
|
||||
let selected_minimum_availability = app
|
||||
.data
|
||||
.radarr_data
|
||||
.movie_minimum_availability_list
|
||||
.current_selection();
|
||||
let selected_quality_profile = app
|
||||
.data
|
||||
.radarr_data
|
||||
.movie_quality_profile_list
|
||||
.current_selection();
|
||||
|
||||
f.render_widget(title_block_centered(&title), prompt_area);
|
||||
|
||||
let chunks = vertical_chunks_with_margin(
|
||||
vec![
|
||||
Constraint::Percentage(35),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Min(0),
|
||||
Constraint::Length(3),
|
||||
],
|
||||
prompt_area,
|
||||
1,
|
||||
);
|
||||
|
||||
let prompt_paragraph = layout_paragraph_borderless(&movie_overview);
|
||||
f.render_widget(prompt_paragraph, chunks[0]);
|
||||
|
||||
let horizontal_chunks = horizontal_chunks(
|
||||
vec![Constraint::Percentage(50), Constraint::Percentage(50)],
|
||||
chunks[7],
|
||||
);
|
||||
|
||||
draw_checkbox_with_label(
|
||||
f,
|
||||
chunks[1],
|
||||
"Monitored",
|
||||
app.data.radarr_data.edit_monitored.unwrap_or_default(),
|
||||
*selected_block == ActiveRadarrBlock::EditMovieToggleMonitored,
|
||||
);
|
||||
|
||||
draw_drop_down_menu_button(
|
||||
f,
|
||||
chunks[2],
|
||||
"Minimum Availability",
|
||||
selected_minimum_availability.to_display_str(),
|
||||
*selected_block == ActiveRadarrBlock::EditMovieSelectMinimumAvailability,
|
||||
);
|
||||
draw_drop_down_menu_button(
|
||||
f,
|
||||
chunks[3],
|
||||
"Quality Profile",
|
||||
selected_quality_profile,
|
||||
*selected_block == ActiveRadarrBlock::EditMovieSelectQualityProfile,
|
||||
);
|
||||
|
||||
if let Route::Radarr(active_radarr_block, _) = *app.get_current_route() {
|
||||
draw_text_box_with_label(
|
||||
f,
|
||||
chunks[4],
|
||||
"Path",
|
||||
&app.data.radarr_data.edit_path,
|
||||
*selected_block == ActiveRadarrBlock::EditMoviePathInput,
|
||||
active_radarr_block == ActiveRadarrBlock::EditMoviePathInput,
|
||||
);
|
||||
draw_text_box_with_label(
|
||||
f,
|
||||
chunks[5],
|
||||
"Tags",
|
||||
&app.data.radarr_data.edit_tags,
|
||||
*selected_block == ActiveRadarrBlock::EditMovieTagsInput,
|
||||
active_radarr_block == ActiveRadarrBlock::EditMovieTagsInput,
|
||||
);
|
||||
}
|
||||
|
||||
draw_button(
|
||||
f,
|
||||
horizontal_chunks[0],
|
||||
"Save",
|
||||
*yes_no_value && highlight_yes_no,
|
||||
);
|
||||
draw_button(
|
||||
f,
|
||||
horizontal_chunks[1],
|
||||
"Cancel",
|
||||
!*yes_no_value && highlight_yes_no,
|
||||
);
|
||||
}
|
||||
+72
-15
@@ -6,12 +6,12 @@ use tui::backend::Backend;
|
||||
use tui::layout::{Alignment, Constraint, Rect};
|
||||
use tui::style::{Color, Style};
|
||||
use tui::text::Text;
|
||||
use tui::widgets::{Cell, Paragraph, Row};
|
||||
use tui::widgets::{Cell, ListItem, Paragraph, Row};
|
||||
use tui::Frame;
|
||||
|
||||
use crate::app::radarr::{
|
||||
ActiveRadarrBlock, RadarrData, ADD_MOVIE_BLOCKS, COLLECTION_DETAILS_BLOCKS, FILTER_BLOCKS,
|
||||
MOVIE_DETAILS_BLOCKS, SEARCH_BLOCKS,
|
||||
ActiveRadarrBlock, RadarrData, ADD_MOVIE_BLOCKS, COLLECTION_DETAILS_BLOCKS, EDIT_MOVIE_BLOCKS,
|
||||
FILTER_BLOCKS, MOVIE_DETAILS_BLOCKS, SEARCH_BLOCKS,
|
||||
};
|
||||
use crate::app::App;
|
||||
use crate::logos::RADARR_LOGO;
|
||||
@@ -19,27 +19,29 @@ use crate::models::radarr_models::{DiskSpace, DownloadRecord, Movie};
|
||||
use crate::models::Route;
|
||||
use crate::ui::radarr_ui::add_movie_ui::draw_add_movie_search_popup;
|
||||
use crate::ui::radarr_ui::collection_details_ui::draw_collection_details_popup;
|
||||
use crate::ui::radarr_ui::edit_movie_ui::draw_edit_movie_prompt;
|
||||
use crate::ui::radarr_ui::movie_details_ui::draw_movie_info_popup;
|
||||
use crate::ui::utils::{
|
||||
borderless_block, get_width_from_percentage, horizontal_chunks, layout_block,
|
||||
layout_block_top_border, line_gauge_with_label, line_gauge_with_title, show_cursor, style_bold,
|
||||
style_default, style_failure, style_primary, style_success, style_warning, title_block,
|
||||
title_block_centered, vertical_chunks_with_margin,
|
||||
style_default, style_failure, style_primary, style_success, style_unmonitored, style_warning,
|
||||
title_block, title_block_centered, vertical_chunks_with_margin,
|
||||
};
|
||||
use crate::ui::{
|
||||
draw_large_popup_over, draw_popup_over, draw_prompt_box, draw_prompt_popup_over, draw_table,
|
||||
draw_tabs, loading, TableProps,
|
||||
draw_drop_down_list, draw_large_popup_over, draw_medium_popup_over, draw_popup, draw_popup_over,
|
||||
draw_prompt_box, draw_prompt_popup_over, draw_table, draw_tabs, loading, TableProps,
|
||||
};
|
||||
use crate::utils::{convert_runtime, convert_to_gb};
|
||||
|
||||
mod add_movie_ui;
|
||||
mod collection_details_ui;
|
||||
mod edit_movie_ui;
|
||||
mod movie_details_ui;
|
||||
|
||||
pub(super) fn draw_radarr_ui<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
|
||||
let (content_rect, _) = draw_tabs(f, area, "Movies", &app.data.radarr_data.main_tabs);
|
||||
|
||||
if let Route::Radarr(active_radarr_block, _) = *app.get_current_route() {
|
||||
if let Route::Radarr(active_radarr_block, context_option) = *app.get_current_route() {
|
||||
match active_radarr_block {
|
||||
ActiveRadarrBlock::Movies => draw_library(f, app, content_rect),
|
||||
ActiveRadarrBlock::SearchMovie => {
|
||||
@@ -97,6 +99,20 @@ pub(super) fn draw_radarr_ui<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, ar
|
||||
draw_collections,
|
||||
draw_collection_details_popup,
|
||||
),
|
||||
_ if EDIT_MOVIE_BLOCKS.contains(&active_radarr_block) => {
|
||||
if let Some(context) = context_option {
|
||||
match context {
|
||||
ActiveRadarrBlock::Movies => {
|
||||
draw_medium_popup_over(f, app, content_rect, draw_library, draw_edit_movie_prompt)
|
||||
}
|
||||
_ if MOVIE_DETAILS_BLOCKS.contains(&context) => {
|
||||
draw_large_popup_over(f, app, content_rect, draw_library, draw_movie_info_popup);
|
||||
draw_popup(f, app, draw_edit_movie_prompt, 60, 60);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
ActiveRadarrBlock::DeleteMoviePrompt => {
|
||||
draw_prompt_popup_over(f, app, content_rect, draw_library, draw_delete_movie_prompt)
|
||||
}
|
||||
@@ -160,19 +176,25 @@ fn draw_library<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
|
||||
table_headers: vec![
|
||||
"Title",
|
||||
"Year",
|
||||
"Studio",
|
||||
"Runtime",
|
||||
"Rating",
|
||||
"Language",
|
||||
"Size",
|
||||
"Quality Profile",
|
||||
"Monitored",
|
||||
"Tags",
|
||||
],
|
||||
constraints: vec![
|
||||
Constraint::Percentage(25),
|
||||
Constraint::Percentage(12),
|
||||
Constraint::Percentage(12),
|
||||
Constraint::Percentage(12),
|
||||
Constraint::Percentage(12),
|
||||
Constraint::Percentage(12),
|
||||
Constraint::Percentage(27),
|
||||
Constraint::Percentage(4),
|
||||
Constraint::Percentage(17),
|
||||
Constraint::Percentage(6),
|
||||
Constraint::Percentage(6),
|
||||
Constraint::Percentage(6),
|
||||
Constraint::Percentage(6),
|
||||
Constraint::Percentage(10),
|
||||
Constraint::Percentage(6),
|
||||
Constraint::Percentage(12),
|
||||
],
|
||||
help: app
|
||||
@@ -182,13 +204,16 @@ fn draw_library<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
|
||||
.get_active_tab_contextual_help(),
|
||||
},
|
||||
|movie| {
|
||||
let monitored = if movie.monitored { "🏷" } else { "" };
|
||||
let (hours, minutes) = convert_runtime(movie.runtime.as_u64().unwrap());
|
||||
let file_size: f64 = convert_to_gb(movie.size_on_disk.as_u64().unwrap());
|
||||
let certification = movie.certification.clone().unwrap_or_else(|| "".to_owned());
|
||||
let tags = "";
|
||||
|
||||
Row::new(vec![
|
||||
Cell::from(movie.title.to_owned()),
|
||||
Cell::from(movie.year.to_string()),
|
||||
Cell::from(movie.studio.to_string()),
|
||||
Cell::from(format!("{}h {}m", hours, minutes)),
|
||||
Cell::from(certification),
|
||||
Cell::from(movie.original_language.name.to_owned()),
|
||||
@@ -199,6 +224,8 @@ fn draw_library<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
|
||||
.unwrap()
|
||||
.to_owned(),
|
||||
),
|
||||
Cell::from(monitored.to_owned()),
|
||||
Cell::from(tags.to_owned()),
|
||||
])
|
||||
.style(determine_row_style(downloads_vec, movie))
|
||||
},
|
||||
@@ -601,5 +628,35 @@ fn determine_row_style(downloads_vec: &[DownloadRecord], movie: &Movie) -> Style
|
||||
return style_failure();
|
||||
}
|
||||
|
||||
style_success()
|
||||
if !movie.monitored {
|
||||
style_unmonitored()
|
||||
} else {
|
||||
style_success()
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_select_minimum_availability_popup<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
app: &mut App,
|
||||
popup_area: Rect,
|
||||
) {
|
||||
draw_drop_down_list(
|
||||
f,
|
||||
popup_area,
|
||||
&mut app.data.radarr_data.movie_minimum_availability_list,
|
||||
|minimum_availability| ListItem::new(minimum_availability.to_display_str().to_owned()),
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_select_quality_profile_popup<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
app: &mut App,
|
||||
popup_area: Rect,
|
||||
) {
|
||||
draw_drop_down_list(
|
||||
f,
|
||||
popup_area,
|
||||
&mut app.data.radarr_data.movie_quality_profile_list,
|
||||
|quality_profile| ListItem::new(quality_profile.clone()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,8 +25,13 @@ use crate::utils::convert_to_gb;
|
||||
pub(super) fn draw_movie_info_popup<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
|
||||
let (content_area, _) = draw_tabs(f, area, "Movie Info", &app.data.radarr_data.movie_info_tabs);
|
||||
|
||||
if let Route::Radarr(active_radarr_block, _) = app.get_current_route() {
|
||||
match active_radarr_block {
|
||||
if let Route::Radarr(active_radarr_block, context_option) = app.get_current_route() {
|
||||
let match_block = if let Some(context) = context_option {
|
||||
context
|
||||
} else {
|
||||
active_radarr_block
|
||||
};
|
||||
match match_block {
|
||||
ActiveRadarrBlock::AutomaticallySearchMoviePrompt => draw_prompt_popup_over(
|
||||
f,
|
||||
app,
|
||||
|
||||
+10
-6
@@ -71,7 +71,7 @@ pub fn layout_button_paragraph(is_selected: bool, label: &str, alignment: Alignm
|
||||
Paragraph::new(Text::from(label))
|
||||
.block(layout_block())
|
||||
.alignment(alignment)
|
||||
.style(style_button_highlight(is_selected))
|
||||
.style(style_block_highlight(is_selected))
|
||||
}
|
||||
|
||||
pub fn layout_button_paragraph_borderless(
|
||||
@@ -82,7 +82,7 @@ pub fn layout_button_paragraph_borderless(
|
||||
Paragraph::new(Text::from(label))
|
||||
.block(borderless_block())
|
||||
.alignment(alignment)
|
||||
.style(style_button_highlight(is_selected))
|
||||
.style(style_block_highlight(is_selected))
|
||||
}
|
||||
|
||||
pub fn layout_paragraph_borderless(string: &str) -> Paragraph {
|
||||
@@ -150,6 +150,10 @@ pub fn style_system_function() -> Style {
|
||||
Style::default().fg(Color::Yellow)
|
||||
}
|
||||
|
||||
pub fn style_unmonitored() -> Style {
|
||||
Style::default().fg(Color::Rgb(91, 87, 87))
|
||||
}
|
||||
|
||||
pub fn style_success() -> Style {
|
||||
Style::default().fg(Color::Green)
|
||||
}
|
||||
@@ -166,7 +170,7 @@ pub fn style_help() -> Style {
|
||||
Style::default().fg(Color::LightBlue)
|
||||
}
|
||||
|
||||
pub fn style_button_highlight(is_selected: bool) -> Style {
|
||||
pub fn style_block_highlight(is_selected: bool) -> Style {
|
||||
if is_selected {
|
||||
style_system_function().add_modifier(Modifier::BOLD)
|
||||
} else {
|
||||
@@ -258,7 +262,7 @@ mod test {
|
||||
horizontal_chunks_with_margin, layout_block, layout_block_bottom_border,
|
||||
layout_block_top_border, layout_block_top_border_with_title, layout_block_with_title,
|
||||
layout_with_constraints, logo_block, spans_info_default, spans_info_primary,
|
||||
spans_info_with_style, style_bold, style_button_highlight, style_default, style_default_bold,
|
||||
spans_info_with_style, style_block_highlight, style_bold, style_default, style_default_bold,
|
||||
style_failure, style_help, style_highlight, style_primary, style_secondary, style_success,
|
||||
style_system_function, style_warning, title_block, title_block_centered, title_style,
|
||||
vertical_chunks, vertical_chunks_with_margin,
|
||||
@@ -550,7 +554,7 @@ mod test {
|
||||
.fg(Color::Yellow)
|
||||
.add_modifier(Modifier::BOLD);
|
||||
|
||||
assert_eq!(style_button_highlight(true), expected_style);
|
||||
assert_eq!(style_block_highlight(true), expected_style);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -559,7 +563,7 @@ mod test {
|
||||
.fg(Color::White)
|
||||
.add_modifier(Modifier::BOLD);
|
||||
|
||||
assert_eq!(style_button_highlight(false), expected_style);
|
||||
assert_eq!(style_block_highlight(false), expected_style);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user