diff options
Diffstat (limited to 'schist_desktop_gui/src/gui/components')
| -rw-r--r-- | schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs | 82 |
1 files changed, 46 insertions, 36 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 index eed55ad..7ceadda 100644 --- 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 @@ -22,54 +22,23 @@ impl<'a> Viewable<'a, Message> for TransactionsView { let columns = [ column( Text::default("Date").width(iced::Length::Fixed(128.0)), - |t: Transaction| { - Text::default(t.date.format("%e %b %Y").as_str()) - .width(iced::Length::Fixed(128.0)) - .small() - .clip() - }, + view_date_cell, ), column( Text::default("Bucket").width(iced::Length::Fixed(128.0)), - |t: Transaction| { - Text::default( - t.bucket_id - .map(|id| id.to_string()) - .unwrap_or(String::from("None")) - .as_str(), - ) - .width(iced::Length::Fixed(128.0)) - .small() - .clip() - }, + |t: Transaction| view_bucket_cell(t), ), column( Text::default("Payee").width(iced::Length::Fixed(256.0)), - |t: Transaction| { - Text::default(&t.counterparty) - .width(iced::Length::Fixed(256.0)) - .small() - .clip() - }, + view_payee_cell, ), column( Text::default("Quantity").width(iced::Length::Fixed(96.0)), - |t: Transaction| { - Text::currency(t.amount) - .width(iced::Length::Fixed(96.0)) - .small() - .clip() - .align_right() - }, + view_quantity_cell, ), column( Text::default("Balance").width(iced::Length::Fixed(96.0)), - |_t: Transaction| { - Text::default("TODO") - .width(iced::Length::Fixed(96.0)) - .small() - .clip() - }, + |_t: Transaction| view_balance_cell(), ), ]; @@ -99,3 +68,44 @@ impl<'a> Viewable<'a, Message> for TransactionsView { .into() } } + +fn view_date_cell(transaction: Transaction) -> Text { + Text::default(transaction.date.format("%e %b %Y").as_str()) + .width(iced::Length::Fixed(128.0)) + .small() + .clip() +} + +fn view_bucket_cell(t: Transaction) -> Text { + Text::default( + t.bucket_id + .map(|id| id.to_string()) + .unwrap_or(String::from("None")) + .as_str(), + ) + .width(iced::Length::Fixed(128.0)) + .small() + .clip() +} + +fn view_payee_cell(t: Transaction) -> Text { + Text::default(&t.counterparty) + .width(iced::Length::Fixed(256.0)) + .small() + .clip() +} + +fn view_quantity_cell(t: Transaction) -> Text { + Text::currency(t.amount) + .width(iced::Length::Fixed(96.0)) + .small() + .clip() + .align_right() +} + +fn view_balance_cell() -> Text { + Text::default("TODO") + .width(iced::Length::Fixed(96.0)) + .small() + .clip() +} |
