summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/gui/components/bucket_name_and_balance.rs
blob: b31e0e2fa7e85129eabf34c3575df0ce6f9e6745 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use iced::{
    widget::{row, text},
    Element,
};
use schist_models::bucket::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> Into<Element<'a, navigation::Message<BucketNameAndBalance>>> for BucketNameAndBalance {
    fn into(self) -> Element<'a, navigation::Message<BucketNameAndBalance>> {
        row![
            text(self.bucket.name.clone()),
            text(self.bucket.balance.unwrap_or(0))
        ]
        .into()
    }
}