mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
fix: Update import path for AppLocalizations in CompassSarList widget
This commit is contained in:
24
lib/utils/sar_marker_extensions.dart
Normal file
24
lib/utils/sar_marker_extensions.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import '../models/sar_marker.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
|
||||
/// Extension for SarMarkerType to provide localized display names
|
||||
extension SarMarkerTypeLocalization on SarMarkerType {
|
||||
/// Get localized display name for this SAR marker type
|
||||
String getLocalizedName(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
switch (this) {
|
||||
case SarMarkerType.foundPerson:
|
||||
return l10n.foundPerson;
|
||||
case SarMarkerType.fire:
|
||||
return l10n.fire;
|
||||
case SarMarkerType.stagingArea:
|
||||
return l10n.stagingArea;
|
||||
case SarMarkerType.object:
|
||||
return 'Object'; // Not commonly used, keeping English for now
|
||||
case SarMarkerType.unknown:
|
||||
return 'Unknown'; // Not commonly used, keeping English for now
|
||||
}
|
||||
}
|
||||
}
|
||||
25
lib/utils/time_ago_extensions.dart
Normal file
25
lib/utils/time_ago_extensions.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
|
||||
/// Extension to provide localized "time ago" formatting
|
||||
extension TimeAgoExtension on Duration {
|
||||
/// Get localized time ago string
|
||||
String toLocalizedTimeAgo(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
if (inMinutes < 1) return l10n.justNow;
|
||||
if (inMinutes < 60) return l10n.minutesAgo(inMinutes);
|
||||
if (inHours < 24) return l10n.hoursAgo(inHours);
|
||||
return l10n.daysAgo(inDays);
|
||||
}
|
||||
|
||||
/// Get localized time ago string with seconds support
|
||||
String toLocalizedTimeAgoWithSeconds(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
if (inSeconds < 60) return l10n.secondsAgo(inSeconds);
|
||||
if (inMinutes < 60) return l10n.minutesAgo(inMinutes);
|
||||
if (inHours < 24) return l10n.hoursAgo(inHours);
|
||||
return l10n.daysAgo(inDays);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user