diff options
| author | Joe Carstairs <me@joeac.net> | 2026-08-28 17:00:27 +0100 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2026-08-28 17:00:27 +0100 |
| commit | 3555fffb71838a1f34421255270913831adb69f0 (patch) | |
| tree | cf02ee7d9f6ab004ce0ba6c07fb60cae24c15feb /schist_desktop_gui/src/gui/components/transactions_view | |
| parent | 988e4670f24994c8cab000c323a607fea284a447 (diff) | |
refactor out transactions table
Diffstat (limited to 'schist_desktop_gui/src/gui/components/transactions_view')
| -rw-r--r-- | schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs | 112 |
1 files changed, 0 insertions, 112 deletions
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 deleted file mode 100644 index 268984b..0000000 --- a/schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs +++ /dev/null @@ -1,112 +0,0 @@ -use iced::{ - alignment, - widget::{ - row, - scrollable::{self, Scrollbar}, - table, - table::column, - Container, Scrollable, - }, - Element, Length, -}; - -use crate::{gui::components::Text, style::SPACING_LG, traits::Viewable}; - -use super::{Message, TransactionRow, TransactionsView}; - -impl<'a> Viewable<'a, Message> for TransactionsView { - fn view(&'a self) -> Element<'a, Message> { - let navigation = self.navigation.view().map(Message::NavigationMessage); - - let columns = [ - column( - Text::default("Date").width(iced::Length::Fixed(128.0)), - view_date_cell, - ), - column( - Text::default("Bucket").width(iced::Length::Fixed(128.0)), - view_bucket_cell, - ), - column( - Text::default("Payee").width(iced::Length::Fixed(256.0)), - view_payee_cell, - ), - column( - Text::default("Quantity") - .width(iced::Length::Fixed(96.0)) - .align_right(), - view_quantity_cell, - ), - column( - Text::default("Balance") - .width(iced::Length::Fixed(96.0)) - .align_right(), - view_balance_cell, - ), - ]; - - let rows = self - .navigation - .active_option - .clone() - .map_or_else(Vec::default, |option| { - self.transaction_rows_by_account_id - .get(&option.account.id) - .cloned() - .unwrap_or_else(Vec::default) - }); - - let table = Scrollable::new(table(columns, rows)).direction(scrollable::Direction::Both { - horizontal: Scrollbar::default(), - vertical: Scrollbar::default(), - }); - - row![ - Container::new(navigation).width(Length::FillPortion(1)), - Container::new(table).width(Length::FillPortion(3)), - ] - .align_y(alignment::Vertical::Center) - .height(Length::Fill) - .spacing(u32::from(SPACING_LG)) - .into() - } -} - -fn view_date_cell(row: TransactionRow) -> Text { - Text::default(row.date.format("%e %b %Y").as_str()) - .width(iced::Length::Fixed(128.0)) - .small() - .clip() -} - -fn view_bucket_cell(row: TransactionRow) -> Text { - Text::default(&row.bucket) - .style(row.bucket_font_style) - .width(iced::Length::Fixed(128.0)) - .small() - .clip() -} - -fn view_payee_cell(row: TransactionRow) -> Text { - Text::default(&row.payee) - .style(row.payee_font_style) - .width(iced::Length::Fixed(256.0)) - .small() - .clip() -} - -fn view_quantity_cell(row: TransactionRow) -> Text { - Text::currency(row.amount) - .width(iced::Length::Fixed(96.0)) - .small() - .clip() - .align_right() -} - -fn view_balance_cell(row: TransactionRow) -> Text { - Text::currency(row.balance) - .width(iced::Length::Fixed(96.0)) - .small() - .clip() - .align_right() -} |
