diff --git a/README.md b/README.md index bca2995..fc68fc3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,3 @@ -

- -

-

Rex

wakatime @@ -57,6 +53,7 @@ cargo run --release **4. Install using a package manager:** * On NetBSD a package is available from the [official repositories](https://pkgsrc.se/finance/rex). To install it simply run: + ```sh pkgin install rex ``` diff --git a/logo.png b/logo.png deleted file mode 100644 index e04ade4..0000000 Binary files a/logo.png and /dev/null differ diff --git a/tui/src/config.rs b/tui/src/config.rs index da2bbd2..f668076 100644 --- a/tui/src/config.rs +++ b/tui/src/config.rs @@ -21,6 +21,7 @@ pub struct Config { pub location: PathBuf, pub backup_db_path: Option>, pub new_location: Option, + pub theme_index: Option, } impl Config { @@ -35,6 +36,7 @@ impl Config { backup_db_path: None, new_location: None, location: target_dir, + theme_index: Some(0), }); } @@ -44,6 +46,11 @@ impl Config { let mut config: Config = serde_json::from_str(&file_content)?; config.location = target_dir; + + if config.theme_index.is_none() { + config.theme_index = Some(0); + } + Ok(config) } @@ -157,6 +164,7 @@ pub fn migrate_config(config_path: &PathBuf) -> Result<()> { backup_db_path: None, new_location: None, location: PathBuf::new(), + theme_index: Some(0), }; let mut backup_path = config_path.to_owned(); diff --git a/tui/src/key_checker/activity.rs b/tui/src/key_checker/activity.rs index 13156ca..51a6aae 100644 --- a/tui/src/key_checker/activity.rs +++ b/tui/src/key_checker/activity.rs @@ -17,6 +17,7 @@ pub fn activity_keys(handler: &mut InputKeyHandler) -> Result handler.go_summary()?, KeyCode::Char('w') => handler.go_search(), KeyCode::Char('v') => handler.show_activity_tx_details()?, + KeyCode::Char('t') => handler.next_theme()?, KeyCode::Right => handler.handle_right_arrow()?, KeyCode::Left => handler.handle_left_arrow()?, KeyCode::Up => handler.handle_up_arrow(), diff --git a/tui/src/key_checker/add_tx.rs b/tui/src/key_checker/add_tx.rs index 6d78b56..c3dc9c8 100644 --- a/tui/src/key_checker/add_tx.rs +++ b/tui/src/key_checker/add_tx.rs @@ -22,6 +22,7 @@ pub fn add_tx_keys(handler: &mut InputKeyHandler) -> Result handler.go_search(), KeyCode::Char('c') => handler.clear_input()?, KeyCode::Char('y') => handler.go_activity(), + KeyCode::Char('t') => handler.next_theme()?, KeyCode::Enter => handler.select_date_field(), KeyCode::Char(c) => { if c.is_numeric() { diff --git a/tui/src/key_checker/chart.rs b/tui/src/key_checker/chart.rs index f71dbc7..1f1454d 100644 --- a/tui/src/key_checker/chart.rs +++ b/tui/src/key_checker/chart.rs @@ -19,6 +19,7 @@ pub fn chart_keys(handler: &mut InputKeyHandler) -> Result handler.do_chart_lgeneds(), KeyCode::Char('w') => handler.go_search(), KeyCode::Char('y') => handler.go_activity(), + KeyCode::Char('t') => handler.next_theme()?, KeyCode::Right => handler.handle_right_arrow()?, KeyCode::Left => handler.handle_left_arrow()?, KeyCode::Up => handler.handle_up_arrow(), diff --git a/tui/src/key_checker/home.rs b/tui/src/key_checker/home.rs index dc6b3bc..e18b0aa 100644 --- a/tui/src/key_checker/home.rs +++ b/tui/src/key_checker/home.rs @@ -22,6 +22,7 @@ pub fn home_keys(handler: &mut InputKeyHandler) -> Result KeyCode::Char(',') => handler.switch_tx_position_up()?, KeyCode::Char('.') => handler.switch_tx_position_down()?, KeyCode::Char('v') => handler.show_home_tx_details(), + KeyCode::Char('t') => handler.next_theme()?, KeyCode::Right => handler.handle_right_arrow()?, KeyCode::Left => handler.handle_left_arrow()?, KeyCode::Up => handler.handle_up_arrow(), diff --git a/tui/src/key_checker/key_handler.rs b/tui/src/key_checker/key_handler.rs index 4937704..27e9a6f 100644 --- a/tui/src/key_checker/key_handler.rs +++ b/tui/src/key_checker/key_handler.rs @@ -1119,6 +1119,14 @@ impl<'a> InputKeyHandler<'a> { pub fn popup_down(&mut self) { self.popup_status.next(); } + + pub fn next_theme(&mut self) -> Result<()> { + let new_index = self.theme.next(); + self.config.theme_index = Some(new_index); + self.config.save_config()?; + + Ok(()) + } } impl InputKeyHandler<'_> { diff --git a/tui/src/key_checker/search.rs b/tui/src/key_checker/search.rs index e42cc16..ee725bd 100644 --- a/tui/src/key_checker/search.rs +++ b/tui/src/key_checker/search.rs @@ -25,6 +25,7 @@ pub fn search_keys(handler: &mut InputKeyHandler) -> Result handler.search_edit_tx()?, KeyCode::Char('d') => handler.do_deletion_popup(), KeyCode::Char('y') => handler.go_activity(), + KeyCode::Char('t') => handler.next_theme()?, KeyCode::Up => handler.handle_up_arrow(), KeyCode::Down => handler.handle_down_arrow(), KeyCode::Enter => handler.select_date_field(), diff --git a/tui/src/key_checker/summary.rs b/tui/src/key_checker/summary.rs index 4fb10a7..db72706 100644 --- a/tui/src/key_checker/summary.rs +++ b/tui/src/key_checker/summary.rs @@ -19,6 +19,7 @@ pub fn summary_keys(handler: &mut InputKeyHandler) -> Result handler.do_summary_hidden_mode(), KeyCode::Char('x') => handler.change_summary_sort(), KeyCode::Char('y') => handler.go_activity(), + KeyCode::Char('t') => handler.next_theme()?, KeyCode::Right => handler.handle_right_arrow()?, KeyCode::Left => handler.handle_left_arrow()?, KeyCode::Up => handler.handle_up_arrow(), diff --git a/tui/src/page_handler/ui_handler.rs b/tui/src/page_handler/ui_handler.rs index 119f68e..84ba4e7 100644 --- a/tui/src/page_handler/ui_handler.rs +++ b/tui/src/page_handler/ui_handler.rs @@ -20,7 +20,7 @@ use crate::pages::{ InfoPopupState, PopupType, activity_ui, add_tx_ui, chart_ui, home_ui, initial_ui, search_ui, summary_ui, }; -use crate::theme::{Theme, ThemeVariant}; +use crate::theme::Theme; use crate::tx_handler::TxData; use crate::utility::LerpState; @@ -33,7 +33,7 @@ pub fn start_app( ) -> Result { // Setting up some default values. Let's go through all of them - let mut theme = Theme::new(ThemeVariant::Light); + let mut theme = Theme::new_index(config.theme_index.unwrap_or(0)); // Contains the homepage month list that is indexed let mut home_months = IndexedData::new_monthly(); diff --git a/tui/src/pages/activity_ui.rs b/tui/src/pages/activity_ui.rs index 4a68625..a321baf 100644 --- a/tui/src/pages/activity_ui.rs +++ b/tui/src/pages/activity_ui.rs @@ -7,7 +7,7 @@ use thousands::Separable; use crate::page_handler::{ActivityTab, IndexedData, TableData}; use crate::theme::Theme; -use crate::utility::{LerpState, create_tab, main_block, styled_block}; +use crate::utility::{LerpState, create_tab, main_block, styled_block, tab_highlight_style}; pub fn activity_ui( f: &mut Frame, @@ -147,25 +147,23 @@ pub fn activity_ui( let mut year_tab = create_tab(years, "Years", theme); match current_tab { - ActivityTab::Months => { - month_tab = month_tab.highlight_style( - Style::default() - .add_modifier(Modifier::BOLD) - .bg(theme.selected()), - ); - } - ActivityTab::Years => { - year_tab = year_tab.highlight_style( - Style::default() - .add_modifier(Modifier::BOLD) - .bg(theme.selected()), - ); - } + ActivityTab::Months => month_tab = month_tab.highlight_style(tab_highlight_style(theme)), + ActivityTab::Years => year_tab = year_tab.highlight_style(tab_highlight_style(theme)), ActivityTab::List => { if table_data.state.selected().is_some() { + let add_modifier = theme.add_reverse_modifier(); + + let mut style = Style::default(); + + if add_modifier { + style = style.fg(theme.selected()).add_modifier(Modifier::REVERSED); + } else { + style = style.bg(theme.selected()); + } + activity_table_area = activity_table_area .highlight_symbol(">> ") - .row_highlight_style(Style::default().bg(theme.selected())); + .row_highlight_style(style); } } } diff --git a/tui/src/pages/chart_ui.rs b/tui/src/pages/chart_ui.rs index 21c9215..5dde2f9 100644 --- a/tui/src/pages/chart_ui.rs +++ b/tui/src/pages/chart_ui.rs @@ -1,7 +1,7 @@ use chrono::{Duration, naive::NaiveDate}; use ratatui::Frame; use ratatui::layout::{Constraint, Direction, Layout}; -use ratatui::style::{Color, Modifier, Style}; +use ratatui::style::{Color, Style}; use ratatui::symbols::Marker; use ratatui::text::Span; use ratatui::widgets::{Axis, Block, Chart, Dataset, GraphType}; @@ -11,7 +11,9 @@ use std::collections::HashMap; use crate::page_handler::{ChartTab, IndexedData}; use crate::theme::Theme; -use crate::utility::{LerpState, create_tab, create_tab_activation, main_block}; +use crate::utility::{ + LerpState, create_tab, create_tab_activation, main_block, tab_highlight_style, +}; /// Creates the balance chart from the transactions pub fn chart_ui( @@ -334,34 +336,14 @@ pub fn chart_ui( ); match current_page { - ChartTab::Months => { - month_tab = month_tab.highlight_style( - Style::default() - .add_modifier(Modifier::BOLD) - .bg(theme.selected()), - ); - } - - ChartTab::Years => { - year_tab = year_tab.highlight_style( - Style::default() - .add_modifier(Modifier::BOLD) - .bg(theme.selected()), - ); - } + ChartTab::Months => month_tab = month_tab.highlight_style(tab_highlight_style(theme)), + ChartTab::Years => year_tab = year_tab.highlight_style(tab_highlight_style(theme)), ChartTab::ModeSelection => { - mode_selection_tab = mode_selection_tab.highlight_style( - Style::default() - .add_modifier(Modifier::BOLD) - .bg(theme.selected()), - ); + mode_selection_tab = mode_selection_tab.highlight_style(tab_highlight_style(theme)); } ChartTab::TxMethods => { - tx_method_selection_tab = tx_method_selection_tab.highlight_style( - Style::default() - .add_modifier(Modifier::BOLD) - .bg(theme.selected()), - ); + tx_method_selection_tab = + tx_method_selection_tab.highlight_style(tab_highlight_style(theme)); } } diff --git a/tui/src/pages/home_ui.rs b/tui/src/pages/home_ui.rs index 711e70c..1e71968 100644 --- a/tui/src/pages/home_ui.rs +++ b/tui/src/pages/home_ui.rs @@ -8,7 +8,7 @@ use thousands::Separable; use crate::page_handler::{HomeRow, HomeTab, IndexedData, TableData}; use crate::theme::Theme; -use crate::utility::{LerpState, create_tab, main_block, styled_block}; +use crate::utility::{LerpState, create_tab, main_block, styled_block, tab_highlight_style}; pub const BALANCE_BOLD: [&str; 7] = [ "Balance", @@ -221,21 +221,8 @@ pub fn home_ui( match current_tab { // Previously added a black block to year and month widget if a value is not selected // Now we will turn that black block into green if a value is selected - HomeTab::Months => { - month_tab = month_tab.highlight_style( - Style::default() - .add_modifier(Modifier::BOLD) - .bg(theme.selected()), - ); - } - - HomeTab::Years => { - year_tab = year_tab.highlight_style( - Style::default() - .add_modifier(Modifier::BOLD) - .bg(theme.selected()), - ); - } + HomeTab::Months => month_tab = month_tab.highlight_style(tab_highlight_style(theme)), + HomeTab::Years => year_tab = year_tab.highlight_style(tab_highlight_style(theme)), // Changes the color of row based on Expense or Income tx type on Transaction widget. HomeTab::Table => { if let Some(a) = home_table.state.selected() { @@ -251,8 +238,17 @@ pub fn home_ui( } else if income_strings.contains(target_string) { table_area = table_area.row_highlight_style(selected_style_income); } else if home_table.items[a][4] == "Transfer" { - table_area = - table_area.row_highlight_style(Style::default().bg(theme.selected())); + let add_modifier = theme.add_reverse_modifier(); + + let mut style = Style::default(); + + if add_modifier { + style = style.fg(theme.selected()).add_modifier(Modifier::REVERSED); + } else { + style = style.bg(theme.selected()); + } + + table_area = table_area.row_highlight_style(style); } } } diff --git a/tui/src/pages/initial_ui.rs b/tui/src/pages/initial_ui.rs index 7e81b93..e8873e5 100644 --- a/tui/src/pages/initial_ui.rs +++ b/tui/src/pages/initial_ui.rs @@ -100,8 +100,11 @@ pub fn initial_ui(f: &mut Frame, start_from: usize, theme: &Theme) { Arrow Left/Right: Cycle values of a widget H: Show help of the page the UI is currently on X: Change sort type on summary/Change date type on Search page -Double R: Go to the Chart page and hide top widget. Press again to unhide -Double Z: Go to the Summary page and hide top widget. Press again to unhide"; +T: Cycle through themes +Double r (Lowercase): Go to the Chart page and hide top widget. Press again to unhide +Double R (Upeercase): Go to the Chart page and hide chart legends. Press again to unhide +Double Z: Go to the Summary page and hide top widget. Press again to unhide +"; let unmodified_third_help = format!( "Arrow Up/Down: Move between year/month/transaction selections and scroll diff --git a/tui/src/pages/popups/help_text.rs b/tui/src/pages/popups/help_text.rs index f2eb692..3c402f6 100644 --- a/tui/src/pages/popups/help_text.rs +++ b/tui/src/pages/popups/help_text.rs @@ -8,6 +8,7 @@ pub const Q: &str = "Q: Quit"; pub const H: &str = "H: Show help"; pub const V: &str = "V: Show selected transaction details"; pub const J: &str = "J: Configuration"; +pub const T: &str = "T: Cycle through themes"; pub fn new_update_text(data: &[String]) -> String { format!( @@ -51,6 +52,7 @@ Empty tags field gets replaced with Unknown. Separate more than 1 tags with a co Example amount: 100 + b, b + b, 5 * b, 1.2k + 1m {F} +{T} {R} {Z} {Y} @@ -76,6 +78,7 @@ Arrow Up/Down: Cycle widgets Arrow Left/Right: Move value of the widget {F} +{T} {A} {Z} {Y} @@ -89,7 +92,8 @@ Arrow Left/Right: Move value of the widget pub fn summary_help_text() -> String { format!( - "This page shows various information based on all transactions primary tag within a given period. Transfer Transaction are not shown here + "This page shows various information based on all transactions primary tag within a given period. +Lend and borrow is based on the current outstanding amount. Following are the supported keys here @@ -100,6 +104,7 @@ Arrow Up/Down: Cycle widgets/table value Arrow Left/Right: Move value of the widget {F} +{T} {A} {R} {Y} @@ -128,6 +133,7 @@ Arrow Left/Right: Move value of the widget Swapping transaction location will only work if they are on the same date. {A} +{T} {R} {Z} {Y} @@ -147,6 +153,7 @@ pub fn search_help_text() -> String { 1: Date Example: 2022-05-12, YYYY-MM-DD 2: TX details Example: For Grocery, Salary 5: TX Type Example: Income/Expense/Transfer/I/E/T +5: New TX Type Example: Borrow/Borrow Repay/Lend/Lend Repay/b/br/l/lr 3: TX Method Example: Cash, Bank, Card 4: Amount Example: 1000, 100+50, b - 100 6: Tags Example: Food, Car. Add a Comma for a new tag @@ -181,6 +188,7 @@ Amount Field: Amount field supports '>' '<' '>=' '<=' highlighting amount \ Example amount : <1000, >=10000 {F} +{T} {A} {R} {Z} @@ -205,6 +213,7 @@ Arrow Up/Down: Cycle widgets Arrow Left/Right: Move value of the widget {F} +{T} {A} {R} {Z} diff --git a/tui/src/pages/popups/models.rs b/tui/src/pages/popups/models.rs index 66c7145..d868298 100644 --- a/tui/src/pages/popups/models.rs +++ b/tui/src/pages/popups/models.rs @@ -316,8 +316,11 @@ impl PopupType { .state .select(Some(selected_index - 1)); } - PopupType::Info(_) | PopupType::Choice(_) => {} - _ => {} + PopupType::Info(_) + | PopupType::Choice(_) + | PopupType::Input(_) + | PopupType::NewPaths(_) + | PopupType::Nothing => {} } } diff --git a/tui/src/pages/search_ui.rs b/tui/src/pages/search_ui.rs index 7b71972..749ebeb 100644 --- a/tui/src/pages/search_ui.rs +++ b/tui/src/pages/search_ui.rs @@ -340,7 +340,17 @@ pub fn search_ui( } else if income_strings.contains(target_string) { table_area = table_area.row_highlight_style(selected_style_income); } else if search_table.items[a][4] == "Transfer" { - table_area = table_area.row_highlight_style(Style::default().bg(theme.selected())); + let add_modifier = theme.add_reverse_modifier(); + + let mut style = Style::default(); + + if add_modifier { + style = style.fg(theme.selected()).add_modifier(Modifier::REVERSED); + } else { + style = style.bg(theme.selected()); + } + + table_area = table_area.row_highlight_style(style); } } diff --git a/tui/src/pages/summary_ui.rs b/tui/src/pages/summary_ui.rs index bdc92cb..2a6249b 100644 --- a/tui/src/pages/summary_ui.rs +++ b/tui/src/pages/summary_ui.rs @@ -10,6 +10,7 @@ use crate::page_handler::{IndexedData, SortingType, SummaryTab, TableData}; use crate::theme::Theme; use crate::utility::{ LerpState, create_tab, main_block, styled_block, styled_block_no_bottom, styled_block_no_top, + tab_highlight_style, }; /// The function draws the Summary page of the interface. @@ -571,31 +572,24 @@ pub fn summary_ui( match current_page { // Previously added a black block to year and month widget if a value is not selected // Now we will turn that black block into green if a value is selected - SummaryTab::Months => { - month_tab = month_tab.highlight_style( - Style::default() - .add_modifier(Modifier::BOLD) - .bg(theme.selected()), - ); - } - - SummaryTab::Years => { - year_tab = year_tab.highlight_style( - Style::default() - .add_modifier(Modifier::BOLD) - .bg(theme.selected()), - ); - } + SummaryTab::Months => month_tab = month_tab.highlight_style(tab_highlight_style(theme)), + SummaryTab::Years => year_tab = year_tab.highlight_style(tab_highlight_style(theme)), SummaryTab::ModeSelection => { - mode_selection_tab = mode_selection_tab.highlight_style( - Style::default() - .add_modifier(Modifier::BOLD) - .bg(theme.selected()), - ); + mode_selection_tab = mode_selection_tab.highlight_style(tab_highlight_style(theme)); } SummaryTab::Table => { + let add_modifier = theme.add_reverse_modifier(); + + let mut style = Style::default(); + + if add_modifier { + style = style.fg(theme.selected()).add_modifier(Modifier::REVERSED); + } else { + style = style.bg(theme.selected()); + } + table_area = table_area - .row_highlight_style(Style::default().bg(theme.selected())) + .row_highlight_style(style) .highlight_symbol(">> "); } } diff --git a/tui/src/theme.rs b/tui/src/theme.rs index a540069..b826d9b 100644 --- a/tui/src/theme.rs +++ b/tui/src/theme.rs @@ -1,69 +1,157 @@ use ratatui::style::Color; +use strum_macros::FromRepr; +#[repr(usize)] +#[derive(FromRepr, Clone, Copy)] pub enum ThemeVariant { Light, + Dracula, + CatppuccinLatte, + CatppuccinFrappe, +} + +impl ThemeVariant { + pub fn next_variant(self) -> Self { + match self { + ThemeVariant::Light => ThemeVariant::Dracula, + ThemeVariant::Dracula => ThemeVariant::CatppuccinLatte, + ThemeVariant::CatppuccinLatte => ThemeVariant::CatppuccinFrappe, + ThemeVariant::CatppuccinFrappe => ThemeVariant::Light, + } + } } pub struct Theme { pub variant: ThemeVariant, + palette: ThemePalette, } impl Theme { pub fn new(variant: ThemeVariant) -> Self { - Self { variant } + let palette = ThemePalette::from_variant(variant); + Self { variant, palette } + } + + pub fn new_index(index: usize) -> Self { + let variant = ThemeVariant::from_repr(index).unwrap_or(ThemeVariant::Light); + Self::new(variant) + } + + pub fn next(&mut self) -> usize { + self.variant = self.variant.next_variant(); + self.palette = ThemePalette::from_variant(self.variant); + + self.variant as usize } pub fn background(&self) -> Color { - match self.variant { - ThemeVariant::Light => Color::Rgb(245, 245, 255), - } + self.palette.background } pub fn text(&self) -> Color { - match self.variant { - ThemeVariant::Light => Color::Rgb(153, 78, 236), - } + self.palette.text } pub fn border(&self) -> Color { - match self.variant { - ThemeVariant::Light => Color::Rgb(255, 87, 51), - } + self.palette.border } pub fn selected(&self) -> Color { - match self.variant { - ThemeVariant::Light => Color::Rgb(151, 251, 151), - } + self.palette.selected } pub fn selectable(&self) -> Color { - match self.variant { - ThemeVariant::Light => Color::Rgb(38, 38, 38), - } + self.palette.selectable } pub fn header(&self) -> Color { - match self.variant { - ThemeVariant::Light => Color::Rgb(0, 150, 255), - } + self.palette.header } pub fn negative(&self) -> Color { - match self.variant { - ThemeVariant::Light => Color::Rgb(255, 51, 51), - } + self.palette.negative } pub fn positive(&self) -> Color { - match self.variant { - ThemeVariant::Light => Color::Rgb(51, 51, 255), - } + self.palette.positive } pub fn autocomplete(&self) -> Color { + self.palette.autocomplete + } + + pub fn add_reverse_modifier(&self) -> bool { match self.variant { - ThemeVariant::Light => Color::Rgb(128, 128, 128), + ThemeVariant::Light => false, + ThemeVariant::Dracula + | ThemeVariant::CatppuccinLatte + | ThemeVariant::CatppuccinFrappe => true, + } + } +} + +struct ThemePalette { + background: Color, + text: Color, + border: Color, + selected: Color, + selectable: Color, + header: Color, + negative: Color, + positive: Color, + autocomplete: Color, +} + +impl ThemePalette { + fn from_variant(variant: ThemeVariant) -> Self { + match variant { + ThemeVariant::Light => Self { + background: Color::Rgb(245, 245, 255), + text: Color::Rgb(153, 78, 236), + border: Color::Rgb(255, 87, 51), + selected: Color::Rgb(151, 251, 151), + selectable: Color::Rgb(38, 38, 38), + header: Color::Rgb(0, 150, 255), + negative: Color::Rgb(255, 51, 51), + positive: Color::Rgb(51, 51, 255), + autocomplete: Color::Rgb(128, 128, 128), + }, + + ThemeVariant::Dracula => Self { + background: Color::Rgb(40, 42, 54), + text: Color::Rgb(248, 248, 242), + border: Color::Rgb(189, 147, 249), + selected: Color::Rgb(255, 184, 108), + selectable: Color::Rgb(98, 114, 164), + header: Color::Rgb(139, 233, 253), + negative: Color::Rgb(255, 85, 85), + positive: Color::Rgb(80, 250, 123), + autocomplete: Color::Rgb(98, 114, 164), + }, + + ThemeVariant::CatppuccinLatte => Self { + background: Color::Rgb(239, 241, 245), + text: Color::Rgb(76, 79, 105), + border: Color::Rgb(30, 102, 245), + selected: Color::Rgb(254, 100, 11), + selectable: Color::Rgb(204, 208, 218), + header: Color::Rgb(114, 135, 253), + negative: Color::Rgb(210, 15, 57), + positive: Color::Rgb(64, 160, 43), + autocomplete: Color::Rgb(108, 111, 133), + }, + + ThemeVariant::CatppuccinFrappe => Self { + background: Color::Rgb(48, 52, 70), + text: Color::Rgb(198, 208, 245), + border: Color::Rgb(202, 158, 230), + selected: Color::Rgb(239, 159, 118), + selectable: Color::Rgb(98, 104, 128), + header: Color::Rgb(140, 170, 238), + negative: Color::Rgb(231, 130, 132), + positive: Color::Rgb(166, 218, 149), + autocomplete: Color::Rgb(127, 132, 156), + }, } } } diff --git a/tui/src/utility/utils.rs b/tui/src/utility/utils.rs index 887c972..eb0448a 100644 --- a/tui/src/utility/utils.rs +++ b/tui/src/utility/utils.rs @@ -282,3 +282,17 @@ pub fn centered_rect_exact(width: u16, height: u16, r: Rect) -> Rect { horizontal[1] } + +pub fn tab_highlight_style(theme: &Theme) -> Style { + let add_modifier = theme.add_reverse_modifier(); + + let mut style = Style::default().add_modifier(Modifier::BOLD); + + if add_modifier { + style = style.fg(theme.selected()).add_modifier(Modifier::REVERSED); + } else { + style = style.bg(theme.selected()); + } + + style +}