mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-27 08:32:33 +01:00
41 lines
1.1 KiB
Dart
41 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
import '../date_time_extension.dart';
|
|
|
|
extension PresenceExtension on CachedPresence {
|
|
String getLocalizedLastActiveAgo(BuildContext context) {
|
|
final lastActiveTimestamp = this.lastActiveTimestamp;
|
|
if (lastActiveTimestamp != null) {
|
|
return L10n.of(context)!
|
|
.lastActiveAgo(lastActiveTimestamp.localizedTimeShort(context));
|
|
}
|
|
return L10n.of(context)!.lastSeenLongTimeAgo;
|
|
}
|
|
|
|
String getLocalizedStatusMessage(BuildContext context) {
|
|
final statusMsg = this.statusMsg;
|
|
if (statusMsg != null && statusMsg.isNotEmpty) {
|
|
return statusMsg;
|
|
}
|
|
if (currentlyActive ?? false) {
|
|
return L10n.of(context)!.currentlyActive;
|
|
}
|
|
return getLocalizedLastActiveAgo(context);
|
|
}
|
|
|
|
Color get color {
|
|
switch (presence) {
|
|
case PresenceType.online:
|
|
return Colors.green;
|
|
case PresenceType.offline:
|
|
return Colors.grey;
|
|
case PresenceType.unavailable:
|
|
default:
|
|
return Colors.red;
|
|
}
|
|
}
|
|
}
|