2020-04-26 18:15:48 +02:00
|
|
|
import 'package:famedlysdk/famedlysdk.dart';
|
|
|
|
import 'package:fluffychat/i18n/i18n.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
extension PresenceExtension on Presence {
|
|
|
|
bool get isStatus =>
|
2020-04-26 19:08:55 +02:00
|
|
|
(statusMsg?.isNotEmpty ?? false) || this.displayname != null;
|
2020-04-26 18:15:48 +02:00
|
|
|
|
|
|
|
String getLocalizedStatusMessage(BuildContext context) {
|
|
|
|
if (!isStatus) return null;
|
|
|
|
if (statusMsg?.isNotEmpty ?? false) {
|
|
|
|
return statusMsg;
|
|
|
|
}
|
|
|
|
if (displayname != null) {
|
|
|
|
return I18n.of(context)
|
|
|
|
.changedTheDisplaynameTo(sender.localpart, displayname);
|
|
|
|
}
|
|
|
|
if (avatarUrl != null) {
|
|
|
|
return I18n.of(context).changedTheProfileAvatar(sender.localpart);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|