diff options
| author | Joe Carstairs <me@joeac.net> | 2026-02-08 15:49:01 +0000 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2026-02-08 15:49:01 +0000 |
| commit | 170c1a58ebd8b6ff1dceb5f46146f76b601c91ad (patch) | |
| tree | bf686c5c4e6e14e05139daf5914bf451724cb583 /schist_desktop_gui/src/gui/components | |
| parent | b9244f6049c685c2b983632359676521506f8772 (diff) | |
task-085: factor out Viewable impl for TransactionsView
Diffstat (limited to 'schist_desktop_gui/src/gui/components')
| -rw-r--r-- | schist_desktop_gui/src/gui/components/transactions_view.rs | 40 | ||||
| -rw-r--r-- | schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs | 41 |
2 files changed, 45 insertions, 36 deletions
diff --git a/schist_desktop_gui/src/gui/components/transactions_view.rs b/schist_desktop_gui/src/gui/components/transactions_view.rs index 6f2ad44..f39b522 100644 --- a/schist_desktop_gui/src/gui/components/transactions_view.rs +++ b/schist_desktop_gui/src/gui/components/transactions_view.rs @@ -1,17 +1,13 @@ +mod view_transactions_view; + use std::collections::HashMap; -use iced::{ - alignment, - widget::{column, row, Container}, - Element, Length, -}; use itertools::Itertools; use schist_models::{Account, Transaction}; use crate::{ - gui::components::{navigation, AccountNavigationEntry, Navigation, Text}, - style::SPACING_LG, - traits::{Component, Viewable}, + gui::components::{navigation, AccountNavigationEntry, Navigation}, + traits::Component, }; #[derive(Clone, Debug)] @@ -52,34 +48,6 @@ impl TransactionsView { } } -impl<'a> Viewable<'a, Message> for TransactionsView { - fn view(&'a self) -> Element<'a, Message> { - let navigation = self.navigation.view().map(Message::NavigationMessage); - let main_content = column![ - Text::default("Hello, transactions!").as_element(), - Text::default(&format!( - "{} transactions in this account.", - self.navigation.active_option.clone().map_or( - 0, - |AccountNavigationEntry { account, .. }| self - .transactions_by_account_id - .get(&account.id) - .map_or(0, |transactions| transactions.len()) - ) - )) - .as_element(), - ]; - row![ - Container::new(navigation).width(Length::FillPortion(1)), - Container::new(main_content).width(Length::FillPortion(3)), - ] - .align_y(alignment::Vertical::Center) - .height(Length::Fill) - .spacing(SPACING_LG) - .into() - } -} - impl<'a> Component<'a, Message, Action> for TransactionsView { fn update(&mut self, message: Message) -> Action { match message { diff --git a/schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs b/schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs new file mode 100644 index 0000000..37b6655 --- /dev/null +++ b/schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs @@ -0,0 +1,41 @@ +use iced::{ + alignment, + widget::{column, row, Container}, + Element, Length, +}; + +use crate::{ + gui::components::{AccountNavigationEntry, Text}, + style::SPACING_LG, + traits::Viewable, +}; + +use super::{Message, TransactionsView}; + +impl<'a> Viewable<'a, Message> for TransactionsView { + fn view(&'a self) -> Element<'a, Message> { + let navigation = self.navigation.view().map(Message::NavigationMessage); + let main_content = column![ + Text::default("Hello, transactions!").as_element(), + Text::default(&format!( + "{} transactions in this account.", + self.navigation.active_option.clone().map_or( + 0, + |AccountNavigationEntry { account, .. }| self + .transactions_by_account_id + .get(&account.id) + .map_or(0, |transactions| transactions.len()) + ) + )) + .as_element(), + ]; + row![ + Container::new(navigation).width(Length::FillPortion(1)), + Container::new(main_content).width(Length::FillPortion(3)), + ] + .align_y(alignment::Vertical::Center) + .height(Length::Fill) + .spacing(SPACING_LG) + .into() + } +} |
