summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/gui/components/balances_view.rs
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2025-08-13 07:50:21 +0000
committerjoeac <me@joeac.net>2025-08-13 07:50:21 +0000
commitee3cd780e21260257b401c3f5cbababd9e27a15a (patch)
treeb0571649a1a1a7644dbc50183cc4c3a29966a963 /schist_desktop_gui/src/gui/components/balances_view.rs
parent49342e8b553d5c92f1c043b3b0ce18bdf1c2cd44 (diff)
task-073
Co-authored-by: Joe Carstairs <jcarstairs@scottlogic.com> Reviewed-on: https://git.joeac.net/joeac/schist/pulls/1 Co-authored-by: Joe Carstairs <me@joeac.net> Co-committed-by: Joe Carstairs <me@joeac.net>
Diffstat (limited to 'schist_desktop_gui/src/gui/components/balances_view.rs')
-rw-r--r--schist_desktop_gui/src/gui/components/balances_view.rs63
1 files changed, 63 insertions, 0 deletions
diff --git a/schist_desktop_gui/src/gui/components/balances_view.rs b/schist_desktop_gui/src/gui/components/balances_view.rs
new file mode 100644
index 0000000..2b72cd3
--- /dev/null
+++ b/schist_desktop_gui/src/gui/components/balances_view.rs
@@ -0,0 +1,63 @@
+mod make_balances_view_greeting;
+mod update_balances_view;
+mod view_balances_view;
+mod view_group_names;
+
+use self::{
+ update_balances_view::update_balances_view, view_balances_view::view_balances_view,
+ view_group_names::view_group_names,
+};
+
+use schist_models::bucket::Bucket;
+
+use crate::{
+ gui::components::{
+ balances_view::make_balances_view_greeting::make_balances_view_greeting, navigation,
+ Navigation, Text,
+ },
+ traits::{Component, Viewable},
+};
+
+#[derive(Clone, Debug)]
+pub struct BalancesView {
+ buckets: Vec<Bucket>,
+ greeting: String,
+ navigation: Navigation<Text>,
+}
+
+#[derive(Clone, Debug)]
+pub enum Message {
+ NavigationMessage(navigation::Message<Text>),
+ SelectNextBucket,
+ SelectPrevBucket,
+ SetBuckets(Vec<Bucket>),
+}
+
+pub enum Action {
+ None,
+}
+
+impl BalancesView {
+ pub fn new(buckets: Vec<Bucket>) -> Self {
+ let groups = view_group_names(buckets.clone());
+ let active_group = groups.clone().first().cloned();
+ let navigation = Navigation::new(active_group.clone(), groups);
+ Self {
+ buckets: buckets.clone(),
+ greeting: make_balances_view_greeting(active_group),
+ navigation: navigation,
+ }
+ }
+}
+
+impl<'a> Viewable<'a, Message> for BalancesView {
+ fn view(&'a self) -> iced::Element<'a, Message> {
+ view_balances_view(self)
+ }
+}
+
+impl<'a> Component<'a, Message, Action> for BalancesView {
+ fn update(&mut self, message: Message) -> Action {
+ update_balances_view(self, message)
+ }
+}