Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementTsang committed Dec 23, 2024
1 parent f4769a0 commit b07aa57
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions src/canvas/widgets/battery_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,30 +165,28 @@ impl Painter {
{
let style = self.styles.text_style;
match &battery_details.state {
BatteryState::Charging { time_to_full } => {
if let Some(secs) = time_to_full {
time = long_time(*secs);

if full_width as usize > time.len() {
battery_rows
.push(Row::new(["Time to empty", &time]).style(style));
} else {
time = short_time(*secs);
battery_rows.push(Row::new(["To empty", &time]).style(style));
}
BatteryState::Charging {
time_to_full: Some(secs),
} => {
time = long_time(*secs);

if full_width as usize > time.len() {
battery_rows.push(Row::new(["Time to full", &time]).style(style));
} else {
time = short_time(*secs);
battery_rows.push(Row::new(["To full", &time]).style(style));
}
}
BatteryState::Discharging { time_to_empty } => {
if let Some(secs) = time_to_empty {
time = long_time(*secs);

if full_width as usize > time.len() {
battery_rows
.push(Row::new(["Time to full", &time]).style(style));
} else {
time = short_time(*secs);
battery_rows.push(Row::new(["To full", &time]).style(style));
}
BatteryState::Discharging {
time_to_empty: Some(secs),
} => {
time = long_time(*secs);

if full_width as usize > time.len() {
battery_rows.push(Row::new(["Time to empty", &time]).style(style));
} else {
time = short_time(*secs);
battery_rows.push(Row::new(["To empty", &time]).style(style));
}
}
_ => {}
Expand Down

0 comments on commit b07aa57

Please sign in to comment.