From 13f4d97a70cfaeb1e78bbc68ff73bd69de081cb2 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Thu, 12 Feb 2026 10:13:03 +0000 Subject: task-085: factor out format_string() --- schist_desktop_gui/src/gui/components/table/view_table.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'schist_desktop_gui/src') 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) } -- cgit v1.2.3