diff options
| author | Joe Carstairs <me@joeac.net> | 2026-01-25 18:18:35 +0000 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2026-01-26 08:31:02 +0000 |
| commit | e35e6d8ba4a7685af6a24b7cd3e77ff19e5f7b80 (patch) | |
| tree | cb8cbc534905c4d4dde979f1919bfead8b5d943b /schist_desktop_gui/src/gui/components/buckets_view.rs | |
| parent | 409b5bc15951001c6d16c2bcfa747fda25cb3735 (diff) | |
refactor bucket_navigation_entry
Diffstat (limited to 'schist_desktop_gui/src/gui/components/buckets_view.rs')
| -rw-r--r-- | schist_desktop_gui/src/gui/components/buckets_view.rs | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/schist_desktop_gui/src/gui/components/buckets_view.rs b/schist_desktop_gui/src/gui/components/buckets_view.rs index cbf7abd..01c91db 100644 --- a/schist_desktop_gui/src/gui/components/buckets_view.rs +++ b/schist_desktop_gui/src/gui/components/buckets_view.rs @@ -6,7 +6,7 @@ use iced::{ use schist_models::Bucket; use crate::{ - gui::components::{navigation, BucketNameAndBalance, Navigation, Text}, + gui::components::{navigation, BucketNavigationEntry, Navigation, Text}, style::SPACING_LG, traits::{Component, Viewable}, }; @@ -14,12 +14,12 @@ use crate::{ #[derive(Clone, Debug)] pub struct BucketsView { greeting: String, - navigation: Navigation<BucketNameAndBalance>, + navigation: Navigation<BucketNavigationEntry>, } #[derive(Clone, Debug)] pub enum Message { - NavigationMessage(navigation::Message<BucketNameAndBalance>), + NavigationMessage(navigation::Message<BucketNavigationEntry>), SelectNextBucket, SelectPrevBucket, SetBuckets(Vec<Bucket>), @@ -34,14 +34,17 @@ impl BucketsView { Self { greeting: greeting.to_owned(), navigation: Navigation::new( - buckets.first().cloned().map(BucketNameAndBalance::new), - buckets.into_iter().map(BucketNameAndBalance::new).collect(), + buckets.first().map(BucketNavigationEntry::from_bucket), + buckets + .iter() + .map(BucketNavigationEntry::from_bucket) + .collect(), ), } } - fn update_greeting(&mut self, active_bucket: &Bucket) { - self.greeting = format!("Hello, {} bucket!", active_bucket.name); + fn update_greeting(&mut self, active_entry: &str) { + self.greeting = format!("Hello, {}!", active_entry); } } @@ -68,21 +71,24 @@ impl<'a> Component<'a, Message, Action> for BucketsView { match message { Message::SetBuckets(buckets) => { self.navigation.update(navigation::Message::SetOptions( - buckets.into_iter().map(BucketNameAndBalance::new).collect(), + buckets + .iter() + .map(BucketNavigationEntry::from_bucket) + .collect(), )); Action::None } Message::NavigationMessage(message) => match self.navigation.update(message) { - navigation::Action::SelectOption(bucket) => { - self.update_greeting(&bucket.bucket); + navigation::Action::SelectOption(bucket_navigation_entry) => { + self.update_greeting(&bucket_navigation_entry.to_string()); Action::None } navigation::Action::None => Action::None, }, Message::SelectNextBucket => { match self.navigation.update(navigation::Message::SelectNext) { - navigation::Action::SelectOption(bucket) => { - self.update_greeting(&bucket.bucket); + navigation::Action::SelectOption(bucket_navigation_entry) => { + self.update_greeting(&bucket_navigation_entry.to_string()); Action::None } navigation::Action::None => Action::None, @@ -90,8 +96,8 @@ impl<'a> Component<'a, Message, Action> for BucketsView { } Message::SelectPrevBucket => { match self.navigation.update(navigation::Message::SelectPrev) { - navigation::Action::SelectOption(bucket) => { - self.update_greeting(&bucket.bucket); + navigation::Action::SelectOption(bucket_navigation_entry) => { + self.update_greeting(&bucket_navigation_entry.to_string()); Action::None } navigation::Action::None => Action::None, |
