Skip to content

Commit

Permalink
Update src/display/components/total_bandwidth.rs
Browse files Browse the repository at this point in the history
Co-Authored-By: ebroto <ebroto@tutanota.com>
  • Loading branch information
zhangxp1998 and ebroto authored Jan 10, 2020
1 parent 691d22f commit f0f3d3c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/display/components/total_bandwidth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,20 @@ pub struct TotalBandwidth<'a> {

impl<'a> TotalBandwidth<'a> {
pub fn render(&self, frame: &mut Frame<impl Backend>, rect: Rect) {
let title_text = [if self.paused {
let title_text = {
let paused_str = if self.paused { "[PAUSED]" } else { "" };
let color = if self.paused { Color::Yellow } else { Color::Green };

[Text::styled(
format!(
" Total Rate Up / Down: {} / {} {}",
DisplayBandwidth(self.state.total_bytes_uploaded as f64),
DisplayBandwidth(self.state.total_bytes_downloaded as f64),
paused_str
),
Style::default().fg(color).modifier(Modifier::BOLD),
)]
};
Text::styled(
format!(
" Total Rate Up / Down: {} / {} [PAUSED]",
Expand Down

0 comments on commit f0f3d3c

Please sign in to comment.