hide counter on empty input

This commit is contained in:
yggverse 2025-01-19 13:20:49 +02:00
parent f3a2a31872
commit b4074e46c3
3 changed files with 5 additions and 5 deletions

View File

@ -38,7 +38,7 @@ impl Control {
// Actions
pub fn update(&self, is_empty: bool, bytes_left: Option<usize>) {
// Update children components
self.counter.update(bytes_left);
self.counter.update(is_empty, bytes_left);
self.send.update(match bytes_left {
Some(left) => !is_empty && left > 0,
None => false,

View File

@ -23,7 +23,7 @@ impl Counter {
}
// Actions
pub fn update(&self, bytes_left: Option<usize>) {
self.widget.update(bytes_left);
pub fn update(&self, is_empty: bool, bytes_left: Option<usize>) {
self.widget.update(is_empty, bytes_left);
}
}

View File

@ -19,7 +19,7 @@ impl Widget {
}
// Actions
pub fn update(&self, bytes_left: Option<usize>) {
pub fn update(&self, is_empty: bool, bytes_left: Option<usize>) {
match bytes_left {
Some(value) => {
// Update color on chars left reached
@ -30,7 +30,7 @@ impl Widget {
self.label.set_label(&value.to_string());
// Toggle visibility on chars left provided
self.label.set_visible(true);
self.label.set_visible(!is_empty);
}
None => self.label.set_visible(false),
}