use std::cmp::Ordering;
use ratatui::style::{Color, Modifier, Style};
pub const FIELD_KEY_STYLE: Style = Style::new().add_modifier(Modifier::BOLD);
pub const FIELD_VALUE_STYLE: Style = Style::new();
pub const ACTIVE_FIELD_STYLE: Style =
Style::new().add_modifier(Modifier::UNDERLINED);
pub const FIELD_VALUE_DELIMITER: &str = ": ";
pub struct LayerInspectorNodeStyles;
impl LayerInspectorNodeStyles {
const SELECTED_NODE_STYLE: Style =
Style::new().add_modifier(Modifier::REVERSED);
const ACTIVE_PANE_ADDED_NODE_STYLE: Style = Style::new().fg(Color::Green);
const ACTIVE_PANE_MODIFIED_NODE_STYLE: Style =
Style::new().fg(Color::Yellow);
const ACTIVE_PANE_DELETED_NODE_STYLE: Style = Style::new().fg(Color::Red);
const INACTIVE_PANE_ADDED_NODE_STYLE: Style =
Style::new().fg(Color::Green).add_modifier(Modifier::DIM);
const INACTIVE_PANE_MODIFIED_NODE_STYLE: Style =
Style::new().fg(Color::Yellow).add_modifier(Modifier::DIM);
const INACTIVE_PANE_DELETED_NODE_STYLE: Style =
Style::new().fg(Color::Red).add_modifier(Modifier::DIM);
pub const fn get_selected_node_style() -> Style {
Self::SELECTED_NODE_STYLE
}
pub const fn get_added_node_style(pane_is_active: bool) -> Style {
if pane_is_active {
return Self::ACTIVE_PANE_ADDED_NODE_STYLE;
}
Self::INACTIVE_PANE_ADDED_NODE_STYLE
}
pub const fn get_modified_node_style(pane_is_active: bool) -> Style {
if pane_is_active {
return Self::ACTIVE_PANE_MODIFIED_NODE_STYLE;
}
Self::INACTIVE_PANE_MODIFIED_NODE_STYLE
}
pub const fn get_deleted_node_style(pane_is_active: bool) -> Style {
if pane_is_active {
return Self::ACTIVE_PANE_DELETED_NODE_STYLE;
}
Self::INACTIVE_PANE_DELETED_NODE_STYLE
}
}
pub fn text_style(pane_is_active: bool) -> Style {
if pane_is_active {
Style::new()
} else {
Style::new().add_modifier(Modifier::DIM)
}
}
pub fn layer_status_indicator_style(
layer_idx: usize,
selected_layer_idx: &usize,
) -> Style {
let style = Style::default();
match layer_idx.cmp(selected_layer_idx) {
Ordering::Equal => style.bg(Color::Green),
Ordering::Less => style.bg(Color::Magenta),
Ordering::Greater => style,
}
}