use iced::{ widget::{row, text}, Element, Length, }; use schist_models::Bucket; use crate::gui::components::navigation; #[derive(Clone, Debug, PartialEq)] pub struct BucketNameAndBalance { pub bucket: Bucket, } impl BucketNameAndBalance { pub fn new(bucket: Bucket) -> Self { Self { bucket } } } impl<'a> From<&'a BucketNameAndBalance> for Element<'a, navigation::Message> { 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(bucket_name_and_balance.bucket.name.clone()).width(Length::Fill), text(bucket_name_and_balance.bucket.pretty_balance_per_100()).style(balance_style), ] .into() } }