Upgraded to Ratatui 0.26 and did a partial refactor to clean up the UI module. Created the ManagarrStyle trait to make it cleaner to use consistent styles across the project. Still need to update the layouts to be consistent with the newer and nicer format. That's a tomorrow problem
This commit is contained in:
@@ -10,7 +10,7 @@ use crate::ui::{
|
||||
draw_button, draw_checkbox_with_label, draw_popup_over, draw_text_box_with_label, loading,
|
||||
DrawUi, LabeledTextBoxProps,
|
||||
};
|
||||
use ratatui::layout::{Constraint, Rect};
|
||||
use ratatui::layout::{Constraint, Layout, Rect};
|
||||
use ratatui::Frame;
|
||||
use std::iter;
|
||||
|
||||
@@ -66,16 +66,14 @@ fn draw_edit_indexer_prompt(f: &mut Frame<'_>, app: &mut App<'_>, prompt_area: R
|
||||
1,
|
||||
);
|
||||
|
||||
let left_chunks = vertical_chunks(
|
||||
vec![
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Min(0),
|
||||
],
|
||||
split_chunks[0],
|
||||
);
|
||||
let [name, rss, auto_search, interactive_search, _] = Layout::vertical([
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Length(3),
|
||||
Constraint::Min(0),
|
||||
])
|
||||
.areas(split_chunks[0]);
|
||||
let right_chunks = vertical_chunks(
|
||||
vec![
|
||||
Constraint::Length(3),
|
||||
@@ -91,7 +89,7 @@ fn draw_edit_indexer_prompt(f: &mut Frame<'_>, app: &mut App<'_>, prompt_area: R
|
||||
draw_text_box_with_label(
|
||||
f,
|
||||
LabeledTextBoxProps {
|
||||
area: left_chunks[0],
|
||||
area: name,
|
||||
label: "Name",
|
||||
text: &edit_indexer_modal.name.text,
|
||||
offset: *edit_indexer_modal.name.offset.borrow(),
|
||||
@@ -166,14 +164,14 @@ fn draw_edit_indexer_prompt(f: &mut Frame<'_>, app: &mut App<'_>, prompt_area: R
|
||||
|
||||
draw_checkbox_with_label(
|
||||
f,
|
||||
left_chunks[1],
|
||||
rss,
|
||||
"Enable RSS",
|
||||
edit_indexer_modal.enable_rss.unwrap_or_default(),
|
||||
selected_block == &ActiveRadarrBlock::EditIndexerToggleEnableRss,
|
||||
);
|
||||
draw_checkbox_with_label(
|
||||
f,
|
||||
left_chunks[2],
|
||||
auto_search,
|
||||
"Enable Automatic Search",
|
||||
edit_indexer_modal
|
||||
.enable_automatic_search
|
||||
@@ -182,7 +180,7 @@ fn draw_edit_indexer_prompt(f: &mut Frame<'_>, app: &mut App<'_>, prompt_area: R
|
||||
);
|
||||
draw_checkbox_with_label(
|
||||
f,
|
||||
left_chunks[3],
|
||||
interactive_search,
|
||||
"Enable Interactive Search",
|
||||
edit_indexer_modal
|
||||
.enable_interactive_search
|
||||
|
||||
@@ -10,7 +10,8 @@ use crate::models::Route;
|
||||
use crate::ui::radarr_ui::indexers::edit_indexer_ui::EditIndexerUi;
|
||||
use crate::ui::radarr_ui::indexers::indexer_settings_ui::IndexerSettingsUi;
|
||||
use crate::ui::radarr_ui::indexers::test_all_indexers_ui::TestAllIndexersUi;
|
||||
use crate::ui::utils::{layout_block_top_border, style_failure, style_primary, style_success};
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::layout_block_top_border;
|
||||
use crate::ui::{draw_prompt_box, draw_prompt_popup_over, draw_table, DrawUi, TableProps};
|
||||
|
||||
mod edit_indexer_ui;
|
||||
@@ -103,24 +104,15 @@ fn draw_indexers(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
} = indexer;
|
||||
let bool_to_text = |flag: bool| {
|
||||
if flag {
|
||||
return ("Enabled", style_success());
|
||||
return Text::from("Enabled").success();
|
||||
}
|
||||
|
||||
("Disabled", style_failure())
|
||||
Text::from("Disabled").failure()
|
||||
};
|
||||
|
||||
let (rss_text, rss_style) = bool_to_text(*enable_rss);
|
||||
let mut rss = Text::from(rss_text);
|
||||
rss.patch_style(rss_style);
|
||||
|
||||
let (auto_search_text, auto_search_style) = bool_to_text(*enable_automatic_search);
|
||||
let mut automatic_search = Text::from(auto_search_text);
|
||||
automatic_search.patch_style(auto_search_style);
|
||||
|
||||
let (interactive_search_text, interactive_search_style) =
|
||||
bool_to_text(*enable_interactive_search);
|
||||
let mut interactive_search = Text::from(interactive_search_text);
|
||||
interactive_search.patch_style(interactive_search_style);
|
||||
let rss = bool_to_text(*enable_rss);
|
||||
let automatic_search = bool_to_text(*enable_automatic_search);
|
||||
let interactive_search = bool_to_text(*enable_interactive_search);
|
||||
let tags: String = tags
|
||||
.iter()
|
||||
.map(|tag_id| {
|
||||
@@ -143,7 +135,7 @@ fn draw_indexers(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
Cell::from(priority.to_string()),
|
||||
Cell::from(tags),
|
||||
])
|
||||
.style(style_primary())
|
||||
.primary()
|
||||
},
|
||||
app.is_loading,
|
||||
true,
|
||||
|
||||
@@ -4,9 +4,8 @@ use crate::models::servarr_data::radarr::modals::IndexerTestResultModalItem;
|
||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||
use crate::models::Route;
|
||||
use crate::ui::radarr_ui::indexers::draw_indexers;
|
||||
use crate::ui::utils::{
|
||||
borderless_block, get_width_from_percentage, style_failure, style_success, title_block,
|
||||
};
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::utils::{borderless_block, get_width_from_percentage, title_block};
|
||||
use crate::ui::{
|
||||
draw_help_and_get_content_rect, draw_large_popup_over, draw_table, DrawUi, TableProps,
|
||||
};
|
||||
@@ -76,18 +75,17 @@ fn draw_test_all_indexers_test_results(f: &mut Frame<'_>, app: &mut App<'_>, are
|
||||
app.tick_count % app.ticks_until_scroll == 0,
|
||||
);
|
||||
let pass_fail = if result.is_valid { "✔" } else { "❌" };
|
||||
let row_style = if result.is_valid {
|
||||
style_success()
|
||||
} else {
|
||||
style_failure()
|
||||
};
|
||||
|
||||
Row::new(vec![
|
||||
let row = Row::new(vec![
|
||||
Cell::from(result.name.to_owned()),
|
||||
Cell::from(pass_fail.to_owned()),
|
||||
Cell::from(result.validation_failures.to_string()),
|
||||
])
|
||||
.style(row_style)
|
||||
]);
|
||||
|
||||
if result.is_valid {
|
||||
row.success()
|
||||
} else {
|
||||
row.failure()
|
||||
}
|
||||
},
|
||||
app.is_loading,
|
||||
true,
|
||||
|
||||
Reference in New Issue
Block a user