Full popup description functionality
This commit is contained in:
+40
-6
@@ -11,7 +11,7 @@ use crate::logos::{
|
||||
};
|
||||
use crate::ui::utils::{
|
||||
centered_rect, horizontal_chunks, horizontal_chunks_with_margin, style_secondary,
|
||||
vertical_chunks, vertical_chunks_with_margin,
|
||||
style_system_function, vertical_chunks, vertical_chunks_with_margin,
|
||||
};
|
||||
|
||||
mod radarr_ui;
|
||||
@@ -27,10 +27,10 @@ pub fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
|
||||
);
|
||||
|
||||
draw_context_row(f, app, main_chunks[0]);
|
||||
match *app.get_current_route() {
|
||||
match app.get_current_route().clone() {
|
||||
Route::Radarr(active_radarr_block) => match active_radarr_block {
|
||||
ActiveRadarrBlock::Movies => radarr_ui::draw_radarr_ui(f, app, main_chunks[1]),
|
||||
ActiveRadarrBlock::MovieDetails => draw_popup_over(
|
||||
ActiveRadarrBlock::MovieDetails => draw_small_popup_over(
|
||||
f,
|
||||
app,
|
||||
main_chunks[1],
|
||||
@@ -48,14 +48,46 @@ pub fn draw_popup_over<B: Backend>(
|
||||
area: Rect,
|
||||
background_fn: fn(&mut Frame<'_, B>, &mut App, Rect),
|
||||
popup_fn: fn(&mut Frame<'_, B>, &App, Rect),
|
||||
percent_x: u16,
|
||||
percent_y: u16,
|
||||
) {
|
||||
background_fn(f, app, area);
|
||||
|
||||
let popup_area = centered_rect(75, 75, f.size());
|
||||
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_small_popup_over<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
app: &mut App,
|
||||
area: Rect,
|
||||
background_fn: fn(&mut Frame<'_, B>, &mut App, Rect),
|
||||
popup_fn: fn(&mut Frame<'_, B>, &App, Rect),
|
||||
) {
|
||||
draw_popup_over(f, app, area, background_fn, popup_fn, 40, 40);
|
||||
}
|
||||
|
||||
pub fn draw_medium_popup_over<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
app: &mut App,
|
||||
area: Rect,
|
||||
background_fn: fn(&mut Frame<'_, B>, &mut App, Rect),
|
||||
popup_fn: fn(&mut Frame<'_, B>, &App, Rect),
|
||||
) {
|
||||
draw_popup_over(f, app, area, background_fn, popup_fn, 60, 60);
|
||||
}
|
||||
|
||||
pub fn draw_large_popup_over<B: Backend>(
|
||||
f: &mut Frame<'_, B>,
|
||||
app: &mut App,
|
||||
area: Rect,
|
||||
background_fn: fn(&mut Frame<'_, B>, &mut App, Rect),
|
||||
popup_fn: fn(&mut Frame<'_, B>, &App, Rect),
|
||||
) {
|
||||
draw_popup_over(f, app, area, background_fn, popup_fn, 75, 75);
|
||||
}
|
||||
|
||||
fn draw_context_row<B: Backend>(f: &mut Frame<'_, B>, app: &App, area: Rect) {
|
||||
let chunks = horizontal_chunks(
|
||||
vec![
|
||||
@@ -80,9 +112,11 @@ pub fn loading<B: Backend>(f: &mut Frame<'_, B>, block: Block<'_>, area: Rect, i
|
||||
if is_loading {
|
||||
let text = "\n\n Loading ...\n\n".to_owned();
|
||||
let mut text = Text::from(text);
|
||||
text.patch_style(style_secondary());
|
||||
text.patch_style(style_system_function());
|
||||
|
||||
let paragraph = Paragraph::new(text).style(style_secondary()).block(block);
|
||||
let paragraph = Paragraph::new(text)
|
||||
.style(style_system_function())
|
||||
.block(block);
|
||||
f.render_widget(paragraph, area);
|
||||
} else {
|
||||
f.render_widget(block, area)
|
||||
|
||||
Reference in New Issue
Block a user