summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/gui
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-02-12 10:13:03 +0000
committerJoe Carstairs <me@joeac.net>2026-02-12 10:13:03 +0000
commit13f4d97a70cfaeb1e78bbc68ff73bd69de081cb2 (patch)
tree9c57a5c1b83f5e8457af5b2ce5b5a7f7963ee673 /schist_desktop_gui/src/gui
parent8f57c4a25e6eb109259a082cd4f1e1007ad4044c (diff)
task-085: factor out format_string()
Diffstat (limited to 'schist_desktop_gui/src/gui')
-rw-r--r--schist_desktop_gui/src/gui/components/table/view_table.rs8
1 files changed, 6 insertions, 2 deletions
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 81755dc..801bbb7 100644
--- a/schist_desktop_gui/src/gui/components/table/view_table.rs
+++ b/schist_desktop_gui/src/gui/components/table/view_table.rs
@@ -26,7 +26,7 @@ where
row_data
.get(&col.index)
.map(|datum| match datum {
- Value::String(text) => Text::default(text).weak(),
+ Value::String(text) => format_string(text),
Value::Currency(amount) => format_currency(*amount),
})
.unwrap_or_else(|| Text::default("")),
@@ -47,11 +47,15 @@ where
}
}
+fn format_string(text: &String) -> Text {
+ Text::default(text).weak()
+}
+
fn format_currency(amount: i32) -> Text {
let text = if amount >= 0 {
format!(" {} · {} ", amount / 100, amount % 100)
} else {
format!("({} · {})", -amount / 100, -amount % 100)
};
- Text::default(&text).align_right().width(iced::Length::Fill)
+ format_string(&text).align_right().width(iced::Length::Fill)
}