diff options
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 | 22 |
1 files changed, 16 insertions, 6 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 f43ee48..4f61493 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 @@ -1,3 +1,5 @@ +use std::collections::HashMap; + use iced::{ alignment, widget::{ @@ -38,7 +40,7 @@ impl<'a> Viewable<'a, Message> for TransactionsView { ), column( Text::default("Balance").width(iced::Length::Fixed(96.0)), - |_t: Transaction| view_balance_cell(), + |t: Transaction| view_balance_cell(t, &self.account_balances_by_transaction_id), ), ]; @@ -106,9 +108,17 @@ fn view_quantity_cell(t: Transaction) -> Text { .align_right() } -fn view_balance_cell() -> Text { - Text::default("TODO") - .width(iced::Length::Fixed(96.0)) - .small() - .clip() +fn view_balance_cell( + transaction: Transaction, + account_balances_by_transaction_id: &HashMap<i32, i32>, +) -> Text { + (account_balances_by_transaction_id + .get(&transaction.id) + .map_or_else( + || Text::default("Error").danger(), + |&balance| Text::currency(balance), + )) + .width(iced::Length::Fixed(96.0)) + .small() + .clip() } |
