Cleaned up some code with some macros
This commit is contained in:
+6
-10
@@ -1,6 +1,5 @@
|
||||
use tui::backend::Backend;
|
||||
use tui::layout::{Alignment, Constraint, Rect};
|
||||
use tui::style::Modifier;
|
||||
use tui::text::{Span, Spans, Text};
|
||||
use tui::widgets::Paragraph;
|
||||
use tui::widgets::Row;
|
||||
@@ -14,10 +13,11 @@ use crate::app::App;
|
||||
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, logo_block,
|
||||
style_button_highlight, 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,
|
||||
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,
|
||||
style_system_function, title_block, title_block_centered, vertical_chunks,
|
||||
vertical_chunks_with_margin,
|
||||
};
|
||||
|
||||
mod radarr_ui;
|
||||
@@ -338,11 +338,7 @@ pub fn draw_prompt_box_with_content<B: Backend>(
|
||||
)
|
||||
};
|
||||
|
||||
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);
|
||||
let prompt_paragraph = layout_paragraph_borderless(prompt);
|
||||
f.render_widget(prompt_paragraph, chunks[0]);
|
||||
|
||||
let horizontal_chunks = horizontal_chunks(
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
use tui::backend::Backend;
|
||||
use tui::layout::{Alignment, Constraint, Rect};
|
||||
use tui::style::Modifier;
|
||||
use tui::text::Text;
|
||||
use tui::widgets::{Cell, ListItem, Paragraph, Row, Wrap};
|
||||
use tui::widgets::{Cell, ListItem, Paragraph, Row};
|
||||
use tui::Frame;
|
||||
|
||||
use crate::app::radarr::ActiveRadarrBlock;
|
||||
use crate::models::radarr_models::AddMovieSearchResult;
|
||||
use crate::models::Route;
|
||||
use crate::ui::utils::{
|
||||
borderless_block, get_width, horizontal_chunks, layout_block, show_cursor, style_default,
|
||||
style_help, style_primary, title_block_centered, vertical_chunks_with_margin,
|
||||
borderless_block, get_width, horizontal_chunks, layout_block, layout_paragraph_borderless,
|
||||
show_cursor, style_default, 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,
|
||||
@@ -293,11 +293,7 @@ fn draw_confirmation_prompt<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, pro
|
||||
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);
|
||||
let prompt_paragraph = layout_paragraph_borderless(&prompt);
|
||||
f.render_widget(prompt_paragraph, chunks[0]);
|
||||
|
||||
let horizontal_chunks = horizontal_chunks(
|
||||
@@ -331,13 +327,13 @@ fn draw_confirmation_prompt<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, pro
|
||||
draw_button(
|
||||
f,
|
||||
horizontal_chunks[0],
|
||||
"Yes",
|
||||
"Add",
|
||||
*yes_no_value && highlight_yes_no,
|
||||
);
|
||||
draw_button(
|
||||
f,
|
||||
horizontal_chunks[1],
|
||||
"No",
|
||||
"Cancel",
|
||||
!*yes_no_value && highlight_yes_no,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,12 +13,12 @@ use crate::models::radarr_models::{Credit, MovieHistoryItem, Release};
|
||||
use crate::models::Route;
|
||||
use crate::ui::utils::{
|
||||
borderless_block, get_width, layout_block_bottom_border, layout_block_top_border,
|
||||
spans_info_default, spans_info_primary, style_bold, style_default, style_failure, style_primary,
|
||||
style_success, style_warning, vertical_chunks,
|
||||
spans_info_default, style_bold, style_default, style_failure, style_primary, style_success,
|
||||
style_warning, vertical_chunks,
|
||||
};
|
||||
use crate::ui::{
|
||||
draw_medium_popup_over, draw_prompt_box, draw_prompt_box_with_content, draw_prompt_popup_over,
|
||||
draw_small_popup_over, draw_table, draw_tabs, loading, TableProps,
|
||||
draw_prompt_box, draw_prompt_box_with_content, draw_prompt_popup_over, draw_small_popup_over,
|
||||
draw_table, draw_tabs, loading, TableProps,
|
||||
};
|
||||
use crate::utils::convert_to_gb;
|
||||
|
||||
|
||||
+9
-1
@@ -2,7 +2,7 @@ use tui::backend::Backend;
|
||||
use tui::layout::{Alignment, Constraint, Direction, Layout, Rect};
|
||||
use tui::style::{Color, Modifier, Style};
|
||||
use tui::text::{Span, Spans, Text};
|
||||
use tui::widgets::{Block, Borders, LineGauge, Paragraph};
|
||||
use tui::widgets::{Block, Borders, LineGauge, Paragraph, Wrap};
|
||||
use tui::{symbols, Frame};
|
||||
|
||||
pub fn horizontal_chunks(constraints: Vec<Constraint>, size: Rect) -> Vec<Rect> {
|
||||
@@ -83,6 +83,14 @@ pub fn layout_button_paragraph_borderless(
|
||||
.style(style_button_highlight(is_selected))
|
||||
}
|
||||
|
||||
pub fn layout_paragraph_borderless(string: &str) -> Paragraph {
|
||||
Paragraph::new(Text::from(string))
|
||||
.block(borderless_block())
|
||||
.style(style_primary().add_modifier(Modifier::BOLD))
|
||||
.wrap(Wrap { trim: false })
|
||||
.alignment(Alignment::Center)
|
||||
}
|
||||
|
||||
pub fn borderless_block<'a>() -> Block<'a> {
|
||||
Block::default()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user