summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/gui
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-02-22 08:36:01 +0000
committerJoe Carstairs <me@joeac.net>2026-02-22 08:36:01 +0000
commitfe1d4bff956d957a6ad2dcd03b15533ec03bf9d6 (patch)
tree4cb2f062ea7d9a72d69363b51890119d87828051 /schist_desktop_gui/src/gui
parentb3d80680c0ac19df7a810ade6f76cabf1005e914 (diff)
task-085: factor out cell view functions
Diffstat (limited to 'schist_desktop_gui/src/gui')
-rw-r--r--schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs82
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()
+}