Added delete movie functionality
This commit is contained in:
+58
-6
@@ -1,8 +1,6 @@
|
||||
use std::iter::Map;
|
||||
use std::slice::Iter;
|
||||
|
||||
use tui::backend::Backend;
|
||||
use tui::layout::{Alignment, Constraint, Rect};
|
||||
use tui::style::{Modifier, Style};
|
||||
use tui::text::{Span, Spans, Text};
|
||||
use tui::widgets::Clear;
|
||||
use tui::widgets::Paragraph;
|
||||
@@ -15,9 +13,10 @@ use tui::Frame;
|
||||
use crate::app::App;
|
||||
use crate::models::{Route, StatefulTable, TabState};
|
||||
use crate::ui::utils::{
|
||||
borderless_block, centered_rect, horizontal_chunks_with_margin, layout_block_top_border,
|
||||
logo_block, style_default_bold, style_failure, style_help, style_highlight, style_primary,
|
||||
style_secondary, style_system_function, title_block, vertical_chunks_with_margin,
|
||||
borderless_block, centered_rect, horizontal_chunks, horizontal_chunks_with_margin, layout_block,
|
||||
layout_block_top_border, logo_block, style_default_bold, style_failure, style_help,
|
||||
style_highlight, style_primary, style_secondary, style_system_function, title_block,
|
||||
vertical_chunks_with_margin,
|
||||
};
|
||||
|
||||
mod radarr_ui;
|
||||
@@ -252,3 +251,56 @@ pub fn loading<B: Backend>(f: &mut Frame<'_, B>, block: Block<'_>, area: Rect, i
|
||||
f.render_widget(block, area)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw_prompt_box<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
prompt_area: Rect,
|
||||
title: &str,
|
||||
prompt: &str,
|
||||
yes_no_value: &bool,
|
||||
) {
|
||||
f.render_widget(
|
||||
title_block(title).title_alignment(Alignment::Center),
|
||||
prompt_area,
|
||||
);
|
||||
|
||||
let chunks = vertical_chunks_with_margin(
|
||||
vec![
|
||||
Constraint::Percentage(72),
|
||||
Constraint::Min(0),
|
||||
Constraint::Length(3),
|
||||
],
|
||||
prompt_area,
|
||||
1,
|
||||
);
|
||||
|
||||
let prompt_paragraph = Paragraph::new(Text::from(prompt))
|
||||
.block(borderless_block())
|
||||
.style(style_primary().add_modifier(Modifier::BOLD))
|
||||
.wrap(Wrap { trim: false })
|
||||
.alignment(Alignment::Center);
|
||||
f.render_widget(prompt_paragraph, chunks[0]);
|
||||
|
||||
let horizontal_chunks = horizontal_chunks(
|
||||
vec![Constraint::Percentage(50), Constraint::Percentage(50)],
|
||||
chunks[2],
|
||||
);
|
||||
|
||||
draw_button(f, horizontal_chunks[0], "Yes", *yes_no_value);
|
||||
draw_button(f, horizontal_chunks[1], "No", !*yes_no_value);
|
||||
}
|
||||
|
||||
pub fn draw_button<B: Backend>(f: &mut Frame<'_, B>, area: Rect, label: &str, is_selected: bool) {
|
||||
let style = if is_selected {
|
||||
style_system_function().add_modifier(Modifier::BOLD)
|
||||
} else {
|
||||
style_default_bold()
|
||||
};
|
||||
|
||||
let label_paragraph = Paragraph::new(Text::from(label))
|
||||
.block(layout_block())
|
||||
.alignment(Alignment::Center)
|
||||
.style(style);
|
||||
|
||||
f.render_widget(label_paragraph, area);
|
||||
}
|
||||
|
||||
+25
-1
@@ -23,7 +23,8 @@ use crate::ui::utils::{
|
||||
vertical_chunks_with_margin,
|
||||
};
|
||||
use crate::ui::{
|
||||
draw_large_popup_over, draw_popup_over, draw_table, draw_tabs, loading, TableProps,
|
||||
draw_large_popup_over, draw_popup_over, draw_prompt_box, draw_table, draw_tabs, loading,
|
||||
TableProps,
|
||||
};
|
||||
use crate::utils::{convert_runtime, convert_to_gb};
|
||||
|
||||
@@ -68,6 +69,15 @@ pub(super) fn draw_radarr_ui<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, ar
|
||||
draw_collection_details_popup,
|
||||
)
|
||||
}
|
||||
ActiveRadarrBlock::DeleteMoviePrompt => draw_popup_over(
|
||||
f,
|
||||
app,
|
||||
content_rect,
|
||||
draw_library,
|
||||
draw_delete_movie_prompt,
|
||||
30,
|
||||
30,
|
||||
),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -141,6 +151,20 @@ fn draw_library<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_delete_movie_prompt<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, prompt_area: Rect) {
|
||||
draw_prompt_box(
|
||||
f,
|
||||
prompt_area,
|
||||
" Confirm Delete Movie? ",
|
||||
format!(
|
||||
"Do you really want to delete {}?",
|
||||
app.data.radarr_data.movies.current_selection().title
|
||||
)
|
||||
.as_str(),
|
||||
&app.data.radarr_data.prompt_confirm,
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_search_box<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area: Rect) {
|
||||
let chunks = vertical_chunks_with_margin(vec![Constraint::Length(3)], area, 1);
|
||||
if !app.data.radarr_data.is_searching {
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ pub fn title_block(title: &str) -> Block<'_> {
|
||||
}
|
||||
|
||||
pub fn logo_block<'a>() -> Block<'a> {
|
||||
Block::default().borders(Borders::ALL).title(Span::styled(
|
||||
layout_block().title(Span::styled(
|
||||
" Managarr - A Servarr management TUI ",
|
||||
Style::default()
|
||||
.fg(Color::Magenta)
|
||||
|
||||
Reference in New Issue
Block a user