Fix chatlistitem context menu
This commit is contained in:
parent
05609314b8
commit
2fc85e0fe3
|
@ -1,4 +1,6 @@
|
||||||
# Version 0.17.0 - 2020-08-??
|
# Version 0.17.0 - 2020-08-??
|
||||||
|
### Features:
|
||||||
|
- Pin and unpin chats
|
||||||
### Fixes:
|
### Fixes:
|
||||||
- Don't re-render the room list nearly as often, increasing performance
|
- Don't re-render the room list nearly as often, increasing performance
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,18 @@ class ChatListItem extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _toggleFavouriteRoom(BuildContext context) =>
|
||||||
|
SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||||
|
room.setFavourite(!room.isFavourite),
|
||||||
|
);
|
||||||
|
|
||||||
|
Future<void> _toggleMuted(BuildContext context) =>
|
||||||
|
SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||||
|
room.setPushRuleState(room.pushRuleState == PushRuleState.notify
|
||||||
|
? PushRuleState.mentions_only
|
||||||
|
: PushRuleState.notify),
|
||||||
|
);
|
||||||
|
|
||||||
Future<bool> archiveAction(BuildContext context) async {
|
Future<bool> archiveAction(BuildContext context) async {
|
||||||
{
|
{
|
||||||
if ([Membership.leave, Membership.ban].contains(room.membership)) {
|
if ([Membership.leave, Membership.ban].contains(room.membership)) {
|
||||||
|
@ -117,9 +129,30 @@ class ChatListItem extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final isMuted = room.pushRuleState == PushRuleState.notify;
|
||||||
|
final slideableKey = GlobalKey();
|
||||||
return Slidable(
|
return Slidable(
|
||||||
key: Key(room.id),
|
key: slideableKey,
|
||||||
secondaryActions: <Widget>[
|
secondaryActions: <Widget>[
|
||||||
|
if ([Membership.join, Membership.invite].contains(room.membership))
|
||||||
|
IconSlideAction(
|
||||||
|
caption: isMuted
|
||||||
|
? L10n.of(context).unmuteChat
|
||||||
|
: L10n.of(context).muteChat,
|
||||||
|
color: Colors.blueGrey,
|
||||||
|
icon:
|
||||||
|
isMuted ? Icons.notifications_active : Icons.notifications_off,
|
||||||
|
onTap: () => _toggleMuted(context),
|
||||||
|
),
|
||||||
|
if ([Membership.join, Membership.invite].contains(room.membership))
|
||||||
|
IconSlideAction(
|
||||||
|
caption: room.isFavourite
|
||||||
|
? L10n.of(context).unpin
|
||||||
|
: L10n.of(context).pin,
|
||||||
|
color: Colors.blue,
|
||||||
|
icon: room.isFavourite ? Icons.favorite_border : Icons.favorite,
|
||||||
|
onTap: () => _toggleFavouriteRoom(context),
|
||||||
|
),
|
||||||
if ([Membership.join, Membership.invite].contains(room.membership))
|
if ([Membership.join, Membership.invite].contains(room.membership))
|
||||||
IconSlideAction(
|
IconSlideAction(
|
||||||
caption: L10n.of(context).leave,
|
caption: L10n.of(context).leave,
|
||||||
|
@ -136,92 +169,107 @@ class ChatListItem extends StatelessWidget {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
actionPane: SlidableDrawerActionPane(),
|
actionPane: SlidableDrawerActionPane(),
|
||||||
dismissal: SlidableDismissal(
|
child: Center(
|
||||||
child: SlidableDrawerDismissal(),
|
child: Material(
|
||||||
onWillDismiss: (actionType) => archiveAction(context),
|
color: chatListItemColor(context, activeChat),
|
||||||
),
|
child: ListTile(
|
||||||
child: Material(
|
onLongPress: () => (slideableKey.currentState as SlidableState)
|
||||||
color: chatListItemColor(context, activeChat),
|
.open(actionType: SlideActionType.secondary),
|
||||||
child: ListTile(
|
leading: Avatar(room.avatar, room.displayname),
|
||||||
leading: Avatar(room.avatar, room.displayname),
|
title: Row(
|
||||||
title: Row(
|
children: <Widget>[
|
||||||
children: <Widget>[
|
Expanded(
|
||||||
Expanded(
|
child: Text(
|
||||||
child: Text(
|
room.getLocalizedDisplayname(L10n.of(context)),
|
||||||
room.getLocalizedDisplayname(L10n.of(context)),
|
maxLines: 1,
|
||||||
maxLines: 1,
|
overflow: TextOverflow.fade,
|
||||||
overflow: TextOverflow.fade,
|
softWrap: false,
|
||||||
softWrap: false,
|
),
|
||||||
),
|
),
|
||||||
),
|
room.isFavourite
|
||||||
SizedBox(width: 4),
|
? Padding(
|
||||||
room.pushRuleState == PushRuleState.notify
|
padding: const EdgeInsets.only(left: 4.0),
|
||||||
? Container()
|
child: Icon(
|
||||||
: Icon(
|
Icons.favorite,
|
||||||
Icons.notifications_off,
|
color: Colors.grey[400],
|
||||||
color: Colors.grey[400],
|
size: 16,
|
||||||
size: 16,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
room.timeCreated.localizedTimeShort(context),
|
|
||||||
style: TextStyle(
|
|
||||||
color: Color(0xFF555555),
|
|
||||||
fontSize: 13,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
subtitle: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: room.membership == Membership.invite
|
|
||||||
? Text(
|
|
||||||
L10n.of(context).youAreInvitedToThisChat,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).primaryColor,
|
|
||||||
),
|
),
|
||||||
softWrap: false,
|
|
||||||
)
|
)
|
||||||
: Text(
|
: Container(),
|
||||||
room.lastEvent?.getLocalizedBody(
|
isMuted
|
||||||
L10n.of(context),
|
? Padding(
|
||||||
withSenderNamePrefix: !room.isDirectChat,
|
padding: const EdgeInsets.only(left: 4.0),
|
||||||
hideReply: true,
|
child: Icon(
|
||||||
) ??
|
Icons.notifications_off,
|
||||||
'',
|
color: Colors.grey[400],
|
||||||
softWrap: false,
|
size: 16,
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.fade,
|
|
||||||
style: TextStyle(
|
|
||||||
decoration: room.lastEvent?.redacted == true
|
|
||||||
? TextDecoration.lineThrough
|
|
||||||
: null,
|
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
),
|
: Container(),
|
||||||
SizedBox(width: 8),
|
Padding(
|
||||||
room.notificationCount > 0
|
padding: const EdgeInsets.only(left: 4.0),
|
||||||
? Container(
|
child: Text(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 5),
|
room.timeCreated.localizedTimeShort(context),
|
||||||
height: 20,
|
style: TextStyle(
|
||||||
decoration: BoxDecoration(
|
color: Color(0xFF555555),
|
||||||
color: room.highlightCount > 0
|
fontSize: 13,
|
||||||
? Colors.red
|
),
|
||||||
: Theme.of(context).primaryColor,
|
),
|
||||||
borderRadius: BorderRadius.circular(20),
|
),
|
||||||
),
|
],
|
||||||
child: Center(
|
),
|
||||||
child: Text(
|
subtitle: Row(
|
||||||
room.notificationCount.toString(),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
style: TextStyle(color: Colors.white),
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: room.membership == Membership.invite
|
||||||
|
? Text(
|
||||||
|
L10n.of(context).youAreInvitedToThisChat,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
),
|
||||||
|
softWrap: false,
|
||||||
|
)
|
||||||
|
: Text(
|
||||||
|
room.lastEvent?.getLocalizedBody(
|
||||||
|
L10n.of(context),
|
||||||
|
withSenderNamePrefix: !room.isDirectChat,
|
||||||
|
hideReply: true,
|
||||||
|
) ??
|
||||||
|
'',
|
||||||
|
softWrap: false,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.fade,
|
||||||
|
style: TextStyle(
|
||||||
|
decoration: room.lastEvent?.redacted == true
|
||||||
|
? TextDecoration.lineThrough
|
||||||
|
: null,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
SizedBox(width: 8),
|
||||||
: Text(' '),
|
room.notificationCount > 0
|
||||||
],
|
? Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 5),
|
||||||
|
height: 20,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: room.highlightCount > 0
|
||||||
|
? Colors.red
|
||||||
|
: Theme.of(context).primaryColor,
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
room.notificationCount.toString(),
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Text(' '),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () => clickAction(context),
|
||||||
),
|
),
|
||||||
onTap: () => clickAction(context),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -617,6 +617,8 @@ class L10n extends MatrixLocalizations {
|
||||||
|
|
||||||
String get pickImage => Intl.message('Pick image');
|
String get pickImage => Intl.message('Pick image');
|
||||||
|
|
||||||
|
String get pin => Intl.message('Pin');
|
||||||
|
|
||||||
String play(String fileName) => Intl.message(
|
String play(String fileName) => Intl.message(
|
||||||
"Play $fileName",
|
"Play $fileName",
|
||||||
name: "play",
|
name: "play",
|
||||||
|
@ -848,6 +850,8 @@ class L10n extends MatrixLocalizations {
|
||||||
args: [type],
|
args: [type],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
String get unpin => Intl.message('Unpin');
|
||||||
|
|
||||||
String unreadChats(String unreadCount) => Intl.message(
|
String unreadChats(String unreadCount) => Intl.message(
|
||||||
"$unreadCount unread chats",
|
"$unreadCount unread chats",
|
||||||
name: "unreadChats",
|
name: "unreadChats",
|
||||||
|
|
33
pubspec.lock
33
pubspec.lock
|
@ -7,14 +7,14 @@ packages:
|
||||||
name: _fe_analyzer_shared
|
name: _fe_analyzer_shared
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.3"
|
version: "6.0.0"
|
||||||
analyzer:
|
analyzer:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: analyzer
|
name: analyzer
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.39.4"
|
version: "0.39.15"
|
||||||
archive:
|
archive:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -85,6 +85,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.3"
|
version: "1.1.3"
|
||||||
|
cli_util:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: cli_util
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.4"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -148,13 +155,6 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.2"
|
version: "4.0.2"
|
||||||
fake_async:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: fake_async
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.0"
|
|
||||||
famedlysdk:
|
famedlysdk:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -547,7 +547,7 @@ packages:
|
||||||
name: path
|
name: path
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.7.0"
|
version: "1.6.4"
|
||||||
path_drawing:
|
path_drawing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -625,6 +625,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.2"
|
version: "1.4.2"
|
||||||
|
quiver:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: quiver
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.3"
|
||||||
random_string:
|
random_string:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -748,21 +755,21 @@ packages:
|
||||||
name: test
|
name: test
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.14.7"
|
version: "1.14.4"
|
||||||
test_api:
|
test_api:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.16"
|
version: "0.2.15"
|
||||||
test_core:
|
test_core:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_core
|
name: test_core
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.7"
|
version: "0.3.4"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
Loading…
Reference in a new issue