From 97b413aa5962bded37dedb380034fa7b97bdc06c Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Sun, 8 Feb 2026 20:26:30 +0000 Subject: task-085: display transaction data in tables --- schist_desktop_gui/src/gui/components/text.rs | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'schist_desktop_gui/src/gui/components/text.rs') diff --git a/schist_desktop_gui/src/gui/components/text.rs b/schist_desktop_gui/src/gui/components/text.rs index d171043..0d0c8c4 100644 --- a/schist_desktop_gui/src/gui/components/text.rs +++ b/schist_desktop_gui/src/gui/components/text.rs @@ -5,12 +5,20 @@ use crate::{impl_focusable, style::*}; #[derive(Clone, Debug, PartialEq)] pub struct Text { pub content: String, + align: Alignment, colour: Option, size: Option, strength: Option, + width: iced::Length, is_focused: bool, } +#[derive(Clone, Debug, PartialEq)] +enum Alignment { + Left, + Right, +} + #[derive(Clone, Debug, PartialEq)] enum Colour { Danger, @@ -33,20 +41,24 @@ enum Size { impl Text { pub fn default(content: &str) -> Self { Self { + align: Alignment::Left, content: String::from(content), colour: Some(Colour::Primary), size: Some(Size::Base), strength: Some(Strength::Base), is_focused: false, + width: iced::Length::Shrink, } } pub fn new(content: &str) -> Self { Self { + align: Alignment::Left, content: String::from(content), colour: None, size: None, strength: None, + width: iced::Length::Shrink, is_focused: false, } } @@ -86,6 +98,20 @@ impl Text { self.clone() } } + + pub fn align_right(&self) -> Self { + Self { + align: Alignment::Right, + ..self.clone() + } + } + + pub fn width(&self, width: iced::Length) -> Self { + Self { + width, + ..self.clone() + } + } } impl<'a, Message> From for iced::Element<'a, Message> { @@ -109,6 +135,11 @@ where Some(Size::Small) => TEXT_SIZE_SM, Some(Size::Base) | None => TEXT_SIZE_BASE, }) + .align_x(match &text.borrow().align { + Alignment::Left => iced::alignment::Horizontal::Left, + Alignment::Right => iced::alignment::Horizontal::Right, + }) + .width(text.borrow().width) .style(move |theme: &iced::Theme| iced::widget::text::Style { color: match ( &text.borrow().borrow().colour, -- cgit v1.2.3 From b1988df5603a427994371d8176bce0c6c1f06fc2 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Thu, 12 Feb 2026 10:14:40 +0000 Subject: task-085: rename small -> v_small --- schist_desktop_gui/src/gui/components/text.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'schist_desktop_gui/src/gui/components/text.rs') diff --git a/schist_desktop_gui/src/gui/components/text.rs b/schist_desktop_gui/src/gui/components/text.rs index 0d0c8c4..b67a7aa 100644 --- a/schist_desktop_gui/src/gui/components/text.rs +++ b/schist_desktop_gui/src/gui/components/text.rs @@ -34,7 +34,7 @@ enum Strength { #[derive(Clone, Debug, PartialEq)] enum Size { - Small, + VSmall, Base, } @@ -67,9 +67,9 @@ impl Text { >>::into(self) } - pub fn small(&self) -> Self { + pub fn v_small(&self) -> Self { Self { - size: Some(Size::Small), + size: Some(Size::VSmall), ..self.clone() } } @@ -132,7 +132,7 @@ where { iced::widget::text(text.borrow().content.clone()) .size(match text.borrow().size { - Some(Size::Small) => TEXT_SIZE_SM, + Some(Size::VSmall) => TEXT_SIZE_V_SM, Some(Size::Base) | None => TEXT_SIZE_BASE, }) .align_x(match &text.borrow().align { -- cgit v1.2.3 From 8659e9df22908fb10afb8d949a523d347634e637 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Thu, 12 Feb 2026 10:18:42 +0000 Subject: task-085: table contents are small text size --- schist_desktop_gui/src/gui/components/text.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'schist_desktop_gui/src/gui/components/text.rs') diff --git a/schist_desktop_gui/src/gui/components/text.rs b/schist_desktop_gui/src/gui/components/text.rs index b67a7aa..36a6a13 100644 --- a/schist_desktop_gui/src/gui/components/text.rs +++ b/schist_desktop_gui/src/gui/components/text.rs @@ -35,6 +35,7 @@ enum Strength { #[derive(Clone, Debug, PartialEq)] enum Size { VSmall, + Small, Base, } @@ -74,6 +75,13 @@ impl Text { } } + pub fn small(&self) -> Self { + Self { + size: Some(Size::Small), + ..self.clone() + } + } + pub fn danger(&self) -> Self { Self { colour: Some(Colour::Danger), @@ -133,6 +141,7 @@ where iced::widget::text(text.borrow().content.clone()) .size(match text.borrow().size { Some(Size::VSmall) => TEXT_SIZE_V_SM, + Some(Size::Small) => TEXT_SIZE_SM, Some(Size::Base) | None => TEXT_SIZE_BASE, }) .align_x(match &text.borrow().align { -- cgit v1.2.3 From b3f91aef7c9673c180690f6e22984d50e0dbeecf Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Thu, 12 Feb 2026 19:11:22 +0000 Subject: task-085: clips overflowing table cells --- schist_desktop_gui/src/gui/components/text.rs | 64 +++++++++++++++++++++------ 1 file changed, 51 insertions(+), 13 deletions(-) (limited to 'schist_desktop_gui/src/gui/components/text.rs') diff --git a/schist_desktop_gui/src/gui/components/text.rs b/schist_desktop_gui/src/gui/components/text.rs index 36a6a13..7a685c1 100644 --- a/schist_desktop_gui/src/gui/components/text.rs +++ b/schist_desktop_gui/src/gui/components/text.rs @@ -1,5 +1,7 @@ use std::borrow::Borrow; +use iced::widget::container; + use crate::{impl_focusable, style::*}; #[derive(Clone, Debug, PartialEq)] @@ -7,6 +9,7 @@ pub struct Text { pub content: String, align: Alignment, colour: Option, + overflow_strategy: OverflowStrategy, size: Option, strength: Option, width: iced::Length, @@ -26,6 +29,12 @@ enum Colour { Highlight, } +#[derive(Clone, Debug, PartialEq)] +enum OverflowStrategy { + Grow, + Clip, +} + #[derive(Clone, Debug, PartialEq)] enum Strength { Base, @@ -45,6 +54,7 @@ impl Text { align: Alignment::Left, content: String::from(content), colour: Some(Colour::Primary), + overflow_strategy: OverflowStrategy::Grow, size: Some(Size::Base), strength: Some(Strength::Base), is_focused: false, @@ -57,6 +67,7 @@ impl Text { align: Alignment::Left, content: String::from(content), colour: None, + overflow_strategy: OverflowStrategy::Grow, size: None, strength: None, width: iced::Length::Shrink, @@ -64,7 +75,10 @@ impl Text { } } - pub fn as_element<'a, Message>(self) -> iced::Element<'a, Message> { + pub fn as_element<'a, Message>(self) -> iced::Element<'a, Message> + where + Message: 'a, + { >>::into(self) } @@ -120,15 +134,28 @@ impl Text { ..self.clone() } } + + pub fn clip(&self) -> Self { + Self { + overflow_strategy: OverflowStrategy::Clip, + ..self.clone() + } + } } -impl<'a, Message> From for iced::Element<'a, Message> { +impl<'a, Message> From for iced::Element<'a, Message> +where + Message: 'a, +{ fn from(text: Text) -> Self { text_as_element(text) } } -impl<'a, Message> From<&'a Text> for iced::Element<'a, Message> { +impl<'a, Message> From<&'a Text> for iced::Element<'a, Message> +where + Message: 'a, +{ fn from(text: &'a Text) -> Self { text_as_element(text) } @@ -137,23 +164,27 @@ impl<'a, Message> From<&'a Text> for iced::Element<'a, Message> { fn text_as_element<'a, T, Message>(text: T) -> iced::Element<'a, Message> where T: Borrow + 'a, + Message: 'a, { - iced::widget::text(text.borrow().content.clone()) + let overflow_strategy = &text.borrow().overflow_strategy.clone(); + + let text_elem: iced::widget::Text = iced::widget::text(text.borrow().content.clone()) .size(match text.borrow().size { - Some(Size::VSmall) => TEXT_SIZE_V_SM, - Some(Size::Small) => TEXT_SIZE_SM, - Some(Size::Base) | None => TEXT_SIZE_BASE, + Some(Size::VSmall) => u32::from(TEXT_SIZE_V_SM), + Some(Size::Small) => u32::from(TEXT_SIZE_SM), + Some(Size::Base) | None => u32::from(TEXT_SIZE_BASE), }) .align_x(match &text.borrow().align { Alignment::Left => iced::alignment::Horizontal::Left, Alignment::Right => iced::alignment::Horizontal::Right, }) + .wrapping(match overflow_strategy { + OverflowStrategy::Grow => iced::widget::text::Wrapping::default(), + OverflowStrategy::Clip => iced::widget::text::Wrapping::None, + }) .width(text.borrow().width) .style(move |theme: &iced::Theme| iced::widget::text::Style { - color: match ( - &text.borrow().borrow().colour, - &text.borrow().borrow().strength, - ) { + color: match (&text.borrow().colour, &text.borrow().strength) { (Some(Colour::Danger), Some(Strength::Base) | None) => { Some(theme.extended_palette().danger.base.text) } @@ -174,8 +205,15 @@ where } (None, _) => None, }, - }) - .into() + }); + + match overflow_strategy { + OverflowStrategy::Grow => text_elem.into(), + OverflowStrategy::Clip => container::<'a, Message, _, _>(text_elem) + .height(iced::Length::Shrink) + .clip(true) + .into(), + } } impl_focusable!(Text); -- cgit v1.2.3 From 413afad1fdf1d15fefc1b709f2eba1332a110608 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Thu, 12 Feb 2026 20:00:26 +0000 Subject: task-085: uses new iced::widget::Table instead of home-made widget --- schist_desktop_gui/src/gui/components/text.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'schist_desktop_gui/src/gui/components/text.rs') diff --git a/schist_desktop_gui/src/gui/components/text.rs b/schist_desktop_gui/src/gui/components/text.rs index 7a685c1..1760f4c 100644 --- a/schist_desktop_gui/src/gui/components/text.rs +++ b/schist_desktop_gui/src/gui/components/text.rs @@ -75,6 +75,15 @@ impl Text { } } + pub fn currency(amount: i32) -> Self { + let formatted_string = if amount < 0 { + format!("({} · {})", -amount / 100, -amount % 100) + } else { + format!(" {} · {} ", amount / 100, amount % 100) + }; + Self::default(&formatted_string) + } + pub fn as_element<'a, Message>(self) -> iced::Element<'a, Message> where Message: 'a, -- cgit v1.2.3 From 376ad725248c9c50596adb8bbebab9d6c5c9dea7 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Sun, 22 Feb 2026 08:45:12 +0000 Subject: task-085: can make Text italic --- schist_desktop_gui/src/gui/components/text.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'schist_desktop_gui/src/gui/components/text.rs') diff --git a/schist_desktop_gui/src/gui/components/text.rs b/schist_desktop_gui/src/gui/components/text.rs index 1760f4c..0cf9698 100644 --- a/schist_desktop_gui/src/gui/components/text.rs +++ b/schist_desktop_gui/src/gui/components/text.rs @@ -1,6 +1,6 @@ use std::borrow::Borrow; -use iced::widget::container; +use iced::{font, widget::container, Font}; use crate::{impl_focusable, style::*}; @@ -9,6 +9,7 @@ pub struct Text { pub content: String, align: Alignment, colour: Option, + font_style: font::Style, overflow_strategy: OverflowStrategy, size: Option, strength: Option, @@ -54,6 +55,7 @@ impl Text { align: Alignment::Left, content: String::from(content), colour: Some(Colour::Primary), + font_style: font::Style::Normal, overflow_strategy: OverflowStrategy::Grow, size: Some(Size::Base), strength: Some(Strength::Base), @@ -67,6 +69,7 @@ impl Text { align: Alignment::Left, content: String::from(content), colour: None, + font_style: font::Style::Normal, overflow_strategy: OverflowStrategy::Grow, size: None, strength: None, @@ -150,6 +153,13 @@ impl Text { ..self.clone() } } + + pub fn italic(&self) -> Self { + Self { + font_style: font::Style::Italic, + ..self.clone() + } + } } impl<'a, Message> From for iced::Element<'a, Message> @@ -178,6 +188,10 @@ where let overflow_strategy = &text.borrow().overflow_strategy.clone(); let text_elem: iced::widget::Text = iced::widget::text(text.borrow().content.clone()) + .font(Font { + style: text.borrow().font_style, + ..Default::default() + }) .size(match text.borrow().size { Some(Size::VSmall) => u32::from(TEXT_SIZE_V_SM), Some(Size::Small) => u32::from(TEXT_SIZE_SM), -- cgit v1.2.3 From 4030a63ac6fe61df87dca07e4143a6b84a9e8475 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Sun, 22 Feb 2026 21:34:24 +0000 Subject: task-085: include account transfers --- schist_desktop_gui/src/gui/components/text.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'schist_desktop_gui/src/gui/components/text.rs') diff --git a/schist_desktop_gui/src/gui/components/text.rs b/schist_desktop_gui/src/gui/components/text.rs index 0cf9698..068e89a 100644 --- a/schist_desktop_gui/src/gui/components/text.rs +++ b/schist_desktop_gui/src/gui/components/text.rs @@ -160,6 +160,13 @@ impl Text { ..self.clone() } } + + pub fn style(&self, font_style: font::Style) -> Self { + Self { + font_style, + ..self.clone() + } + } } impl<'a, Message> From for iced::Element<'a, Message> -- cgit v1.2.3