// Display formatting shared by the screens. Unknown values render as "—" // rather than 0, so a missing Remote ID field never reads as a real reading. String fmtMeters(double? m, {int digits = 0}) => m == null ? '—' : '${m.toStringAsFixed(digits)} m'; String fmtDistance(double? m) { if (m == null) return '—'; if (m < 1000) return '${m.round()} m'; return '${(m / 1000).toStringAsFixed(2)} km'; } String fmtSpeed(double? ms) => ms == null ? '—' : '${ms.toStringAsFixed(1)} m/s'; String fmtDuration(Duration d) { final int h = d.inHours; final String m = (d.inMinutes % 60).toString().padLeft(2, '0'); final String s = (d.inSeconds % 60).toString().padLeft(2, '0'); return h > 0 ? '$h:$m:$s' : '$m:$s'; } String fmtAgo(DateTime t, [DateTime? now]) { final Duration d = (now ?? DateTime.now()).difference(t); if (d.inSeconds < 2) return 'now'; if (d.inSeconds < 60) return '${d.inSeconds} s ago'; if (d.inMinutes < 60) return '${d.inMinutes} min ago'; return '${d.inHours} h ago'; } String fmtClock(DateTime t) { final DateTime l = t.toLocal(); return '${l.hour.toString().padLeft(2, '0')}:${l.minute.toString().padLeft(2, '0')}'; } const Map purposeLabels = { 'commercial': 'Commercial', 'hobby': 'Hobby', 'research': 'Research', 'public': 'Public service', 'club_area': 'Club area', }; const Map categoryLabels = { 'open': 'Open', 'specific': 'Specific', 'certified': 'Certified', }; String transportLabel(String t) => switch (t) { 'ble' => 'Bluetooth', 'ble5' => 'Bluetooth 5 LR', 'nan' => 'Wi-Fi NaN', 'beacon' => 'Wi-Fi Beacon', _ => t, };