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

View File

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

View File

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