mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-09-21 08:47:53 +02:00
bug: fix issue with battery widget time and small widths (#1787)
* bug: fix issue with battery time and small widths * changelog
This commit is contained in:
parent
e23af2f393
commit
849edf71db
@ -24,7 +24,8 @@ That said, these are more guidelines rather than hardset rules, though the proje
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [#1776](https://github.com/ClementTsang/bottom/pull/1776): Fix disk.columns being incorrectly interpreted as blank.
|
||||
- [#1776](https://github.com/ClementTsang/bottom/pull/1776): Fix `disk.columns` being incorrectly interpreted as blank.
|
||||
- [1787](https://github.com/ClementTsang/bottom/pull/1787): Fix issue with battery widget time and small widths.
|
||||
|
||||
## [0.11.0] - 2025-08-05
|
||||
|
||||
|
@ -117,11 +117,11 @@ impl Painter {
|
||||
|
||||
let is_basic = app_state.app_config_fields.use_basic_mode;
|
||||
|
||||
let margined_draw_loc = Layout::default()
|
||||
let [margined_draw_loc] = Layout::default()
|
||||
.constraints([Constraint::Percentage(100)])
|
||||
.horizontal_margin(u16::from(is_basic && !is_selected))
|
||||
.direction(Direction::Horizontal)
|
||||
.split(draw_loc)[0];
|
||||
.areas(draw_loc);
|
||||
|
||||
if let Some(battery_details) =
|
||||
battery_harvest.get(battery_widget_state.currently_selected_battery_index)
|
||||
@ -168,13 +168,15 @@ impl Painter {
|
||||
let mut time: String; // Keep string lifetime in scope.
|
||||
{
|
||||
let style = self.styles.text_style;
|
||||
let time_width = (full_width / 2) as usize;
|
||||
|
||||
match &battery_details.state {
|
||||
BatteryState::Charging {
|
||||
time_to_full: Some(secs),
|
||||
} => {
|
||||
time = long_time(*secs);
|
||||
|
||||
if full_width as usize > time.len() {
|
||||
if time_width >= time.len() {
|
||||
battery_rows.push(Row::new(["Time to full", &time]).style(style));
|
||||
} else {
|
||||
time = short_time(*secs);
|
||||
@ -186,7 +188,7 @@ impl Painter {
|
||||
} => {
|
||||
time = long_time(*secs);
|
||||
|
||||
if full_width as usize > time.len() {
|
||||
if time_width >= time.len() {
|
||||
battery_rows.push(Row::new(["Time to empty", &time]).style(style));
|
||||
} else {
|
||||
time = short_time(*secs);
|
||||
|
Loading…
x
Reference in New Issue
Block a user