FurryChat/lib/utils/presence_extension.dart
Marcel b6d2ddaf7d feat!: Use new localisation setup from flutter 1.22
BREAKING CHANGE: This introduces that it might require up to 2 compiles for locals to work.
Also only arb files shall be checked into git.

Took 19 minutes
2020-10-03 11:11:07 +00:00

23 lines
745 B
Dart

import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'date_time_extension.dart';
extension PresenceExtension on Presence {
String getLocalizedStatusMessage(BuildContext context) {
if (presence.statusMsg?.isNotEmpty ?? false) {
return presence.statusMsg;
}
if (presence.lastActiveAgo != null ?? presence.lastActiveAgo != 0) {
return L10n.of(context).lastActiveAgo(
DateTime.fromMillisecondsSinceEpoch(presence.lastActiveAgo)
.localizedTimeShort(context));
}
if (presence.currentlyActive) {
return L10n.of(context).currentlyActive;
}
return L10n.of(context).lastSeenLongTimeAgo;
}
}