Skip to content

Commit

Permalink
Ctrl + g to switch themes
Browse files Browse the repository at this point in the history
[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Appeased the linter
  • Loading branch information
Xithrius committed Oct 27, 2023
1 parent 9a40526 commit ba3783d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/handlers/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
_ => {
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,6 @@ impl CompleteConfig {
self.frontend.theme = match self.frontend.theme {
Theme::Dark => Theme::Light,
_ => Theme::Dark,
}
};
}
}
8 changes: 6 additions & 2 deletions src/ui/components/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
},
};
Expand Down Expand Up @@ -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,
Expand Down
21 changes: 17 additions & 4 deletions src/utils/styles.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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(),
};
Expand Down

0 comments on commit ba3783d

Please sign in to comment.