mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 13:09:24 +01:00
presence representation
This commit is contained in:
parent
7a8c22c376
commit
2f79d4b5c7
@ -28,6 +28,7 @@ class PresenceListItem extends StatelessWidget {
|
|||||||
return FutureBuilder<Profile>(
|
return FutureBuilder<Profile>(
|
||||||
future: _requestProfile(context),
|
future: _requestProfile(context),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
|
if (!snapshot.hasData) return Container();
|
||||||
Uri avatarUrl;
|
Uri avatarUrl;
|
||||||
String displayname = presence.sender.localpart;
|
String displayname = presence.sender.localpart;
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
@ -48,7 +49,6 @@ class PresenceListItem extends StatelessWidget {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (presence.isStatus)
|
|
||||||
Text(presence.getLocalizedStatusMessage(context)),
|
Text(presence.getLocalizedStatusMessage(context)),
|
||||||
if (presence.presence != null)
|
if (presence.presence != null)
|
||||||
Text(
|
Text(
|
||||||
|
@ -423,6 +423,12 @@ class I18n extends MatrixLocalizations {
|
|||||||
args: [username],
|
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 lastSeenIp => Intl.message("Last seen IP");
|
||||||
|
|
||||||
String get license => Intl.message("License");
|
String get license => Intl.message("License");
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
import 'package:fluffychat/i18n/i18n.dart';
|
import 'package:fluffychat/i18n/i18n.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'date_time_extension.dart';
|
||||||
|
|
||||||
extension PresenceExtension on Presence {
|
extension PresenceExtension on Presence {
|
||||||
bool get isStatus =>
|
|
||||||
(statusMsg?.isNotEmpty ?? false) || this.displayname != null;
|
|
||||||
|
|
||||||
String getLocalizedStatusMessage(BuildContext context) {
|
String getLocalizedStatusMessage(BuildContext context) {
|
||||||
if (!isStatus) return '';
|
|
||||||
if (statusMsg?.isNotEmpty ?? false) {
|
if (statusMsg?.isNotEmpty ?? false) {
|
||||||
return statusMsg;
|
return statusMsg;
|
||||||
}
|
}
|
||||||
@ -15,9 +12,6 @@ extension PresenceExtension on Presence {
|
|||||||
return I18n.of(context)
|
return I18n.of(context)
|
||||||
.changedTheDisplaynameTo(sender.localpart, displayname);
|
.changedTheDisplaynameTo(sender.localpart, displayname);
|
||||||
}
|
}
|
||||||
if (avatarUrl != null) {
|
return I18n.of(context).lastActiveAgo(time.localizedTimeShort(context));
|
||||||
return I18n.of(context).changedTheProfileAvatar(sender.localpart);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user