diff options
Diffstat (limited to 'schist_desktop_gui/src/gui/components')
| -rw-r--r-- | schist_desktop_gui/src/gui/components/table.rs | 13 | ||||
| -rw-r--r-- | schist_desktop_gui/src/gui/components/table/view_table.rs | 9 | ||||
| -rw-r--r-- | schist_desktop_gui/src/gui/components/transactions_view.rs | 6 |
3 files changed, 20 insertions, 8 deletions
diff --git a/schist_desktop_gui/src/gui/components/table.rs b/schist_desktop_gui/src/gui/components/table.rs index 4c6d810..68090c1 100644 --- a/schist_desktop_gui/src/gui/components/table.rs +++ b/schist_desktop_gui/src/gui/components/table.rs @@ -24,6 +24,7 @@ where { pub index: Ix, pub name: String, + pub width: f32, } impl<Ix> Column<Ix> @@ -34,8 +35,20 @@ where Self { index, name: name.to_string(), + width: 128.0, } } + + pub fn width(&self, width: f32) -> Self { + Self { + width, + ..self.clone() + } + } + + pub fn mul_width(&self, mul: f32) -> Self { + self.width(self.width * mul) + } } #[derive(Clone, Debug)] diff --git a/schist_desktop_gui/src/gui/components/table/view_table.rs b/schist_desktop_gui/src/gui/components/table/view_table.rs index 33fa0ef..81755dc 100644 --- a/schist_desktop_gui/src/gui/components/table/view_table.rs +++ b/schist_desktop_gui/src/gui/components/table/view_table.rs @@ -15,11 +15,10 @@ where fn view(&'a self) -> iced::Element<'a, Message> { let headers = row(self.cols.iter().map(|col| { container(Text::default(&col.name)) - .width(iced::Length::Fixed(128.0)) + .width(iced::Length::Fixed(col.width)) .into() })) - .spacing(SPACING_MD) - .padding(SPACING_MD); + .spacing(SPACING_MD); let rows = column(self.rows.iter().map(|row_data| { row(self.cols.iter().map(|col| { @@ -32,14 +31,14 @@ where }) .unwrap_or_else(|| Text::default("")), ) - .width(iced::Length::Fixed(128.0)) + .width(iced::Length::Fixed(col.width)) .into() })) .spacing(SPACING_MD) .into() })); - scrollable(column![headers, rows]) + scrollable(column![headers, rows].spacing(SPACING_MD)) .direction(ScrollableDirection::Both { horizontal: Default::default(), vertical: Default::default(), diff --git a/schist_desktop_gui/src/gui/components/transactions_view.rs b/schist_desktop_gui/src/gui/components/transactions_view.rs index 8e076f1..e78a142 100644 --- a/schist_desktop_gui/src/gui/components/transactions_view.rs +++ b/schist_desktop_gui/src/gui/components/transactions_view.rs @@ -60,9 +60,9 @@ impl TransactionsView { cols: vec![ table::Column::new(0, "Date"), table::Column::new(1, "Bucket"), - table::Column::new(2, "Payee"), - table::Column::new(3, "Quantity"), - table::Column::new(4, "Balance"), + table::Column::new(2, "Payee").mul_width(1.5), + table::Column::new(3, "Quantity").mul_width(0.67), + table::Column::new(4, "Balance").mul_width(0.67), ], rows: self.navigation.active_option.clone().map_or_else( Vec::new, |
