Implement status feature and new design
This commit is contained in:
parent
a361ee53f0
commit
a4d34cb0b1
7 changed files with 344 additions and 155 deletions
11
lib/utils/client_presence_extension.dart
Normal file
11
lib/utils/client_presence_extension.dart
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'presence_extension.dart';
|
||||
|
||||
extension ClientPresenceExtension on Client {
|
||||
List<Presence> get statusList {
|
||||
final statusList = presences.values.toList();
|
||||
statusList.removeWhere((Presence p) => !p.isStatus);
|
||||
statusList.sort((a, b) => b.time.compareTo(a.time));
|
||||
return statusList;
|
||||
}
|
||||
}
|
||||
25
lib/utils/presence_extension.dart
Normal file
25
lib/utils/presence_extension.dart
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension PresenceExtension on Presence {
|
||||
bool get isStatus =>
|
||||
(statusMsg?.isNotEmpty ?? false) ||
|
||||
this.displayname != null ||
|
||||
this.avatarUrl != null;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue