build: Upgraded to Ratatui v0.30.0 and fixed a new security vulnerability [#13]
This commit is contained in:
+22
-20
@@ -1,8 +1,10 @@
|
||||
use crate::ui::THEME;
|
||||
use crate::ui::styles::ManagarrStyle;
|
||||
use crate::ui::styles::{
|
||||
ManagarrStyle, default_style, failure_style, primary_style, secondary_style,
|
||||
system_function_style,
|
||||
};
|
||||
use ratatui::layout::{Alignment, Constraint, Layout, Rect};
|
||||
use ratatui::style::{Style, Stylize};
|
||||
use ratatui::symbols;
|
||||
use ratatui::text::{Line, Span, Text};
|
||||
use ratatui::widgets::{Block, BorderType, Borders, LineGauge, ListItem, Paragraph, Wrap};
|
||||
|
||||
@@ -37,11 +39,11 @@ pub fn layout_block_top_border_with_title(title_span: Span<'_>) -> Block<'_> {
|
||||
}
|
||||
|
||||
pub fn layout_block_top_border<'a>() -> Block<'a> {
|
||||
Block::new().borders(Borders::TOP).default()
|
||||
Block::new().borders(Borders::TOP).default_color()
|
||||
}
|
||||
|
||||
pub fn layout_block_bottom_border<'a>() -> Block<'a> {
|
||||
Block::new().borders(Borders::BOTTOM).default()
|
||||
Block::new().borders(Borders::BOTTOM).default_color()
|
||||
}
|
||||
|
||||
pub fn layout_paragraph_borderless(string: &str) -> Paragraph<'_> {
|
||||
@@ -54,14 +56,14 @@ pub fn layout_paragraph_borderless(string: &str) -> Paragraph<'_> {
|
||||
}
|
||||
|
||||
pub fn borderless_block<'a>() -> Block<'a> {
|
||||
Block::new().default()
|
||||
Block::new().default_color()
|
||||
}
|
||||
|
||||
pub fn style_block_highlight(is_selected: bool) -> Style {
|
||||
if is_selected {
|
||||
Style::new().system_function().bold()
|
||||
system_function_style().bold()
|
||||
} else {
|
||||
Style::new().default().bold()
|
||||
default_style().bold()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +76,7 @@ pub fn unstyled_title_block(title: &str) -> Block<'_> {
|
||||
}
|
||||
|
||||
pub fn title_block(title: &str) -> Block<'_> {
|
||||
unstyled_title_block(title).default()
|
||||
unstyled_title_block(title).default_color()
|
||||
}
|
||||
|
||||
pub fn title_block_centered(title: &str) -> Block<'_> {
|
||||
@@ -82,7 +84,7 @@ pub fn title_block_centered(title: &str) -> Block<'_> {
|
||||
}
|
||||
|
||||
pub fn logo_block<'a>() -> Block<'a> {
|
||||
layout_block().default().title(Span::styled(
|
||||
layout_block().default_color().title(Span::styled(
|
||||
" Managarr - A Servarr management TUI ",
|
||||
Style::new().magenta().bold().italic(),
|
||||
))
|
||||
@@ -107,19 +109,19 @@ pub fn centered_rect(percent_x: u16, percent_y: u16, area: Rect) -> Rect {
|
||||
}
|
||||
|
||||
pub fn line_gauge_with_title(title: &str, ratio: f64) -> LineGauge<'_> {
|
||||
LineGauge::new()
|
||||
LineGauge::default()
|
||||
.block(Block::new().title(title))
|
||||
.filled_style(Style::new().primary())
|
||||
.line_set(symbols::line::THICK)
|
||||
.filled_style(primary_style())
|
||||
.filled_symbol("━")
|
||||
.ratio(ratio)
|
||||
.label(Line::from(format!("{:.0}%", ratio * 100.0)))
|
||||
}
|
||||
|
||||
pub fn line_gauge_with_label(title: &str, ratio: f64) -> LineGauge<'_> {
|
||||
LineGauge::new()
|
||||
LineGauge::default()
|
||||
.block(Block::new())
|
||||
.filled_style(Style::new().primary())
|
||||
.line_set(symbols::line::THICK)
|
||||
.filled_style(primary_style())
|
||||
.filled_symbol("━")
|
||||
.ratio(ratio)
|
||||
.label(Line::from(format!("{title}: {:.0}%", ratio * 100.0)))
|
||||
}
|
||||
@@ -132,11 +134,11 @@ pub(super) fn style_log_list_item(list_item: ListItem<'_>, level: String) -> Lis
|
||||
match level.to_lowercase().as_str() {
|
||||
"trace" => list_item.gray(),
|
||||
"debug" => list_item.blue(),
|
||||
"info" => list_item.style(Style::new().default()),
|
||||
"warn" => list_item.style(Style::new().secondary()),
|
||||
"error" => list_item.style(Style::new().failure()),
|
||||
"fatal" => list_item.style(Style::new().failure().bold()),
|
||||
_ => list_item.style(Style::new().default()),
|
||||
"info" => list_item.style(default_style()),
|
||||
"warn" => list_item.style(secondary_style()),
|
||||
"error" => list_item.style(failure_style()),
|
||||
"fatal" => list_item.style(failure_style().bold()),
|
||||
_ => list_item.style(default_style()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user