summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/gui/components/transactions_view
diff options
context:
space:
mode:
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.rs85
1 files changed, 81 insertions, 4 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 8102314..72f4c8f 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,10 +1,17 @@
use iced::{
alignment,
- widget::{row, Container},
+ widget::{
+ row,
+ scrollable::{self, Scrollbar},
+ table,
+ table::column,
+ Container, Scrollable,
+ },
Element, Length,
};
+use schist_models::Transaction;
-use crate::{style::SPACING_LG, traits::Viewable};
+use crate::{gui::components::Text, style::SPACING_LG, traits::Viewable};
use super::{Message, TransactionsView};
@@ -12,11 +19,81 @@ impl<'a> Viewable<'a, Message> for TransactionsView {
fn view(&'a self) -> Element<'a, Message> {
let navigation = self.navigation.view().map(Message::NavigationMessage);
- let table = self.table.view().map(Message::TableMessage);
+ let columns = [
+ column(
+ Text::default("Date").width(iced::Length::Fixed(128.0)),
+ |t: Transaction| {
+ Text::default(t.date.to_string().as_str())
+ .width(iced::Length::Fixed(128.0))
+ .small()
+ .clip()
+ },
+ ),
+ 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()
+ },
+ ),
+ column(
+ Text::default("Payee").width(iced::Length::Fixed(256.0)),
+ |t: Transaction| {
+ Text::default(&t.counterparty)
+ .width(iced::Length::Fixed(256.0))
+ .small()
+ .clip()
+ },
+ ),
+ 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()
+ },
+ ),
+ column(
+ Text::default("Balance").width(iced::Length::Fixed(96.0)),
+ |_t: Transaction| {
+ Text::default("TODO")
+ .width(iced::Length::Fixed(96.0))
+ .small()
+ .clip()
+ },
+ ),
+ ];
+
+ let rows = self
+ .navigation
+ .active_option
+ .clone()
+ .map_or_else(Vec::default, |option| {
+ self.transactions_by_account_id
+ .get(&option.account.id)
+ .cloned()
+ .unwrap_or_else(Vec::default)
+ });
+
+ let table = table(columns, rows);
row![
Container::new(navigation).width(Length::FillPortion(1)),
- Container::new(table).width(Length::FillPortion(3)),
+ Scrollable::new(table)
+ .direction(scrollable::Direction::Both {
+ horizontal: Scrollbar::default(),
+ vertical: Scrollbar::default(),
+ })
+ .width(Length::FillPortion(3)),
]
.align_y(alignment::Vertical::Center)
.height(Length::Fill)