app working with sandbox

This commit is contained in:
davmar
2026-09-06 21:13:30 +02:00
parent 8475abeddb
commit 773187f0af
18 changed files with 1909 additions and 100 deletions
+28
View File
@@ -57,3 +57,31 @@ String labelForThemeMode(ThemeMode mode) {
ThemeMode.system => 'System',
};
}
/// Formats a money amount with currency code, e.g. `1 234,56 EUR`.
String formatMoney(double amount, String currency) {
final sign = amount < 0 ? '-' : '';
final abs = amount.abs();
final fixed = abs.toStringAsFixed(2);
final parts = fixed.split('.');
final whole = parts[0];
final fraction = parts.length > 1 ? parts[1] : '00';
final buffer = StringBuffer();
for (var i = 0; i < whole.length; i++) {
final fromEnd = whole.length - i;
buffer.write(whole[i]);
if (fromEnd > 1 && fromEnd % 3 == 1) {
buffer.write('\u00a0');
}
}
return '$sign${buffer.toString()},$fraction $currency';
}
/// Formats an ISO date string (`yyyy-MM-dd` or full ISO) for list rows.
String formatIsoDate(String raw) {
if (raw.isEmpty) return '';
final parsed = DateTime.tryParse(raw);
if (parsed == null) return raw;
return formatDate(parsed);
}