summaryrefslogtreecommitdiff
path: root/schist_desktop_gui
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-01-09 18:13:36 +0000
committerJoe Carstairs <me@joeac.net>2026-01-17 09:39:15 +0000
commit1056421dd45b7e9af6f63a95026cb069cfa34e29 (patch)
tree38c8253a1c84cba3af1ff5bee9d2bd4e5cec8768 /schist_desktop_gui
parent43e4dd1bd0258bfc5164ac8e0d83c12840f23719 (diff)
improves balance format/style
Diffstat (limited to 'schist_desktop_gui')
-rw-r--r--schist_desktop_gui/src/gui/components/bucket_name_and_balance.rs28
1 files changed, 17 insertions, 11 deletions
diff --git a/schist_desktop_gui/src/gui/components/bucket_name_and_balance.rs b/schist_desktop_gui/src/gui/components/bucket_name_and_balance.rs
index b08729c..8a5a16e 100644
--- a/schist_desktop_gui/src/gui/components/bucket_name_and_balance.rs
+++ b/schist_desktop_gui/src/gui/components/bucket_name_and_balance.rs
@@ -1,7 +1,10 @@
-use iced::{widget::row, Element};
+use iced::{
+ widget::{row, text},
+ Element, Length,
+};
use schist_models::Bucket;
-use crate::gui::components::{navigation, Text};
+use crate::gui::components::navigation;
#[derive(Clone, Debug, PartialEq)]
pub struct BucketNameAndBalance {
@@ -16,16 +19,19 @@ impl BucketNameAndBalance {
impl<'a> From<&'a BucketNameAndBalance> for Element<'a, navigation::Message<BucketNameAndBalance>> {
fn from(bucket_name_and_balance: &'a BucketNameAndBalance) -> Self {
+ let balance_style = if bucket_name_and_balance
+ .bucket
+ .balance
+ .is_none_or(|balance| balance >= 0)
+ {
+ text::default
+ } else {
+ text::danger
+ };
+
row![
- Text::new(&bucket_name_and_balance.bucket.name).as_element(),
- Text::new(
- &bucket_name_and_balance
- .bucket
- .balance
- .unwrap_or(0)
- .to_string()
- )
- .as_element(),
+ text(bucket_name_and_balance.bucket.name.clone()).width(Length::Fill),
+ text(bucket_name_and_balance.bucket.pretty_balance_per_100()).style(balance_style),
]
.into()
}