Use theme for push gauge

This commit is contained in:
Richard Menzies 2020-11-13 13:36:27 +00:00 committed by Stephan Dilly
parent c37f229070
commit f3b7b0ffac
2 changed files with 13 additions and 7 deletions

View file

@ -23,7 +23,6 @@ use crossterm::event::Event;
use tui::{
backend::Backend,
layout::Rect,
style::{Color, Style},
text::Span,
widgets::{Block, BorderType, Borders, Clear, Gauge},
Frame,
@ -188,12 +187,7 @@ impl DrawableComponent for PushComponent {
.border_type(BorderType::Thick)
.border_style(self.theme.block(true)),
)
.gauge_style(
//TODO: use theme
Style::default()
.fg(Color::White)
.bg(Color::Black),
)
.gauge_style(self.theme.push_gauge())
.percent(u16::from(progress)),
area,
);

View file

@ -47,6 +47,10 @@ pub struct Theme {
commit_author: Color,
#[serde(with = "Color")]
danger_fg: Color,
#[serde(with = "Color")]
push_gauge_bg: Color,
#[serde(with = "Color")]
push_gauge_fg: Color,
}
impl Theme {
@ -220,6 +224,12 @@ impl Theme {
)
}
pub fn push_gauge(&self) -> Style {
Style::default()
.fg(self.push_gauge_fg)
.bg(self.push_gauge_bg)
}
fn save(&self) -> Result<()> {
let theme_file = Self::get_theme_file()?;
let mut file = File::create(theme_file)?;
@ -276,6 +286,8 @@ impl Default for Theme {
commit_time: Color::LightCyan,
commit_author: Color::Green,
danger_fg: Color::Red,
push_gauge_bg: Color::White,
push_gauge_fg: Color::Red,
}
}
}