summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/gui/components/text.rs
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-02-08 20:26:30 +0000
committerJoe Carstairs <me@joeac.net>2026-02-08 20:26:30 +0000
commit97b413aa5962bded37dedb380034fa7b97bdc06c (patch)
tree2cb96478c3808e027528a175e673f77dcc328f9d /schist_desktop_gui/src/gui/components/text.rs
parent170c1a58ebd8b6ff1dceb5f46146f76b601c91ad (diff)
task-085: display transaction data in tables
Diffstat (limited to 'schist_desktop_gui/src/gui/components/text.rs')
-rw-r--r--schist_desktop_gui/src/gui/components/text.rs31
1 files changed, 31 insertions, 0 deletions
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,13 +5,21 @@ use crate::{impl_focusable, style::*};
#[derive(Clone, Debug, PartialEq)]
pub struct Text {
pub content: String,
+ align: Alignment,
colour: Option<Colour>,
size: Option<Size>,
strength: Option<Strength>,
+ width: iced::Length,
is_focused: bool,
}
#[derive(Clone, Debug, PartialEq)]
+enum Alignment {
+ Left,
+ Right,
+}
+
+#[derive(Clone, Debug, PartialEq)]
enum Colour {
Danger,
Primary,
@@ -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<Text> 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,