mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 04:59:26 +01:00
presence representation
This commit is contained in:
parent
7a8c22c376
commit
2f79d4b5c7
@ -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,
|
||||
|
@ -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");
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user