From ba3783d8677fe026823be0cb29b05b97c626ad1a Mon Sep 17 00:00:00 2001 From: Xithrius Date: Thu, 26 Oct 2023 21:39:18 -0700 Subject: [PATCH] `Ctrl + g` to switch themes [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Appeased the linter --- src/handlers/app.rs | 2 +- src/handlers/config.rs | 2 +- src/ui/components/chat.rs | 8 ++++++-- src/utils/styles.rs | 21 +++++++++++++++++---- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/handlers/app.rs b/src/handlers/app.rs index bce73641..9b0c3911 100644 --- a/src/handlers/app.rs +++ b/src/handlers/app.rs @@ -152,7 +152,7 @@ impl App { Key::Ctrl('d') => { self.components.debug.toggle_focus(); } - Key::Ctrl('.') => { + Key::Ctrl('g') => { self.config.borrow_mut().rotate_theme(); } _ => { diff --git a/src/handlers/config.rs b/src/handlers/config.rs index 5308b288..e94f87bd 100644 --- a/src/handlers/config.rs +++ b/src/handlers/config.rs @@ -533,6 +533,6 @@ impl CompleteConfig { self.frontend.theme = match self.frontend.theme { Theme::Dark => Theme::Light, _ => Theme::Dark, - } + }; } } diff --git a/src/ui/components/chat.rs b/src/ui/components/chat.rs index aaa97cd5..f2b96fc5 100644 --- a/src/ui/components/chat.rs +++ b/src/ui/components/chat.rs @@ -31,7 +31,7 @@ use crate::{ Component, MessageSearchWidget, }, utils::{ - styles::{BORDER_DARK, BORDER_LIGHT}, + styles::{BORDER_DARK, BORDER_LIGHT, WINDOW_DARK, WINDOW_LIGHT}, text::{title_line, TitleStyle}, }, }; @@ -297,7 +297,11 @@ impl Component for ChatWidget { Block::default() .borders(Borders::ALL) .border_type(self.config.borrow().frontend.border_type.clone().into()) - .title(chat_title), + .title(chat_title) + .style(match self.config.borrow().frontend.theme { + Theme::Dark => WINDOW_DARK, + _ => WINDOW_LIGHT, + }), ) .style(match self.config.borrow().frontend.theme { Theme::Dark => BORDER_DARK, diff --git a/src/utils/styles.rs b/src/utils/styles.rs index 644d3d8d..381b0ae2 100644 --- a/src/utils/styles.rs +++ b/src/utils/styles.rs @@ -1,5 +1,18 @@ use tui::style::{Color, Modifier, Style}; +pub const WINDOW_DARK: Style = Style { + fg: None, + bg: None, + add_modifier: Modifier::empty(), + sub_modifier: Modifier::empty(), +}; +pub const WINDOW_LIGHT: Style = Style { + fg: None, + bg: Some(Color::White), + add_modifier: Modifier::empty(), + sub_modifier: Modifier::empty(), +}; + pub const BORDER_DARK: Style = Style { fg: Some(Color::White), bg: None, @@ -29,14 +42,14 @@ pub const DATETIME_LIGHT: Style = Style { }; pub const HIGHLIGHT_NAME_DARK: Style = Style { - fg: Some(Color::Black), - bg: Some(Color::White), + fg: Some(Color::Rgb(83, 83, 95)), + bg: Some(Color::Rgb(173, 173, 184)), add_modifier: Modifier::BOLD, sub_modifier: Modifier::empty(), }; pub const HIGHLIGHT_NAME_LIGHT: Style = Style { - fg: Some(Color::White), - bg: Some(Color::Black), + fg: Some(Color::Rgb(173, 173, 184)), + bg: Some(Color::Rgb(83, 83, 95)), add_modifier: Modifier::BOLD, sub_modifier: Modifier::empty(), };