feat: reformat some pages

This commit is contained in:
2026-10-26 23:15:05 +01:00
parent 65e5e286b0
commit 08f4847800
17 changed files with 812 additions and 198 deletions
+29
View File
@@ -1,4 +1,7 @@
import 'package:intl/intl.dart';
import '../models/app_error.dart';
import '../models/remote_command.dart';
import '../models/update_failure.dart';
import 'app_localizations.dart';
@@ -17,6 +20,32 @@ extension AppLocalizationsHelpers on AppLocalizations {
};
}
/// "just now", "5 minutes ago"…, and the full date once a day has passed.
String relativeTime(DateTime time, String locale, {DateTime? now}) {
final elapsed = (now ?? DateTime.now()).difference(time);
if (elapsed.inMinutes < 1) return justNow;
if (elapsed.inHours < 1) return minutesAgo(elapsed.inMinutes);
if (elapsed.inDays < 1) return hoursAgo(elapsed.inHours);
return DateFormat.yMMMd(locale).add_jm().format(time.toLocal());
}
String remoteCommandLabel(String rawType) {
return switch (CommandType.fromValue(rawType)) {
CommandType.closeTab => remoteCommandCloseTab,
null => remoteCommandUnknown(rawType),
};
}
String commandResultLabel(CommandResult result) {
return switch (result) {
CommandResult.completed => commandCompleted,
CommandResult.conflict => commandConflict,
CommandResult.failed => commandFailed,
CommandResult.expired => commandExpired,
};
}
String errorText(AppError? error) {
return switch (error) {
null => genericError,