29 lines
985 B
Dart
29 lines
985 B
Dart
|
|
import '../../../../core/localization/app_localizations.dart';
|
||
|
|
|
||
|
|
String deviceAlarmTime(DateTime? time) {
|
||
|
|
if (time == null) return '—';
|
||
|
|
String two(int value) => value.toString().padLeft(2, '0');
|
||
|
|
return '${time.year}-${two(time.month)}-${two(time.day)} '
|
||
|
|
'${two(time.hour)}:${two(time.minute)}:${two(time.second)}';
|
||
|
|
}
|
||
|
|
|
||
|
|
String deviceAlarmLevel(AppLocalizations l10n, String level) {
|
||
|
|
if (level.toUpperCase() == 'WARNING') {
|
||
|
|
return l10n.translate('device_alarms.level_warning');
|
||
|
|
}
|
||
|
|
if (const ['1', '2', '3', '4'].contains(level)) {
|
||
|
|
return l10n.translate('device_alarms.level_$level');
|
||
|
|
}
|
||
|
|
return level.isEmpty ? '—' : level;
|
||
|
|
}
|
||
|
|
|
||
|
|
String deviceAlarmType(AppLocalizations l10n, String type) {
|
||
|
|
if (type.toUpperCase() == 'MOWER_FAULT') {
|
||
|
|
return l10n.translate('device_alarms.type_mower_fault');
|
||
|
|
}
|
||
|
|
if (const ['1', '2', '3', '4', '5', '6'].contains(type)) {
|
||
|
|
return l10n.translate('device_alarms.type_$type');
|
||
|
|
}
|
||
|
|
return type.isEmpty ? '—' : type;
|
||
|
|
}
|