presence representation

This commit is contained in:
Christian Pauly 2020-05-06 18:31:38 +02:00
parent 7a8c22c376
commit 2f79d4b5c7
3 changed files with 10 additions and 10 deletions

View File

@ -28,6 +28,7 @@ class PresenceListItem extends StatelessWidget {
return FutureBuilder<Profile>(
future: _requestProfile(context),
builder: (context, snapshot) {
if (!snapshot.hasData) return Container();
Uri avatarUrl;
String displayname = presence.sender.localpart;
if (snapshot.hasData) {
@ -48,8 +49,7 @@ class PresenceListItem extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (presence.isStatus)
Text(presence.getLocalizedStatusMessage(context)),
Text(presence.getLocalizedStatusMessage(context)),
if (presence.presence != null)
Text(
presence.presence.toString().split('.').last,

View File

@ -423,6 +423,12 @@ class I18n extends MatrixLocalizations {
args: [username],
);
String lastActiveAgo(String localizedTimeShort) => Intl.message(
"Last active: localizedTimeShort",
name: "lastActiveAgo",
args: [localizedTimeShort],
);
String get lastSeenIp => Intl.message("Last seen IP");
String get license => Intl.message("License");

View File

@ -1,13 +1,10 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:flutter/material.dart';
import 'date_time_extension.dart';
extension PresenceExtension on Presence {
bool get isStatus =>
(statusMsg?.isNotEmpty ?? false) || this.displayname != null;
String getLocalizedStatusMessage(BuildContext context) {
if (!isStatus) return '';
if (statusMsg?.isNotEmpty ?? false) {
return statusMsg;
}
@ -15,9 +12,6 @@ extension PresenceExtension on Presence {
return I18n.of(context)
.changedTheDisplaynameTo(sender.localpart, displayname);
}
if (avatarUrl != null) {
return I18n.of(context).changedTheProfileAvatar(sender.localpart);
}
return null;
return I18n.of(context).lastActiveAgo(time.localizedTimeShort(context));
}
}