Krille/remove status feature
This commit is contained in:
parent
61ceb7d723
commit
e3f1fc757c
13 changed files with 372 additions and 651 deletions
|
|
@ -4,21 +4,37 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|||
|
||||
import 'date_time_extension.dart';
|
||||
|
||||
extension on PresenceType {
|
||||
String getLocalized(BuildContext context) {
|
||||
switch (this) {
|
||||
case PresenceType.online:
|
||||
return L10n.of(context).online;
|
||||
case PresenceType.unavailable:
|
||||
return L10n.of(context).unavailable;
|
||||
case PresenceType.offline:
|
||||
default:
|
||||
return L10n.of(context).offline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension PresenceExtension on Presence {
|
||||
bool get isUserStatus => presence?.statusMsg?.isNotEmpty ?? false;
|
||||
String getLocalizedLastActiveAgo(BuildContext context) {
|
||||
if (presence.lastActiveAgo != null && presence.lastActiveAgo != 0) {
|
||||
return L10n.of(context).lastActiveAgo(DateTime.fromMillisecondsSinceEpoch(
|
||||
DateTime.now().millisecondsSinceEpoch - presence.lastActiveAgo)
|
||||
.localizedTimeShort(context));
|
||||
}
|
||||
return L10n.of(context).lastSeenLongTimeAgo;
|
||||
}
|
||||
|
||||
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;
|
||||
return presence.presence.getLocalized(context);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue