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,13 +169,12 @@ class ChatListItem extends StatelessWidget {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
actionPane: SlidableDrawerActionPane(),
|
actionPane: SlidableDrawerActionPane(),
|
||||||
dismissal: SlidableDismissal(
|
child: Center(
|
||||||
child: SlidableDrawerDismissal(),
|
|
||||||
onWillDismiss: (actionType) => archiveAction(context),
|
|
||||||
),
|
|
||||||
child: Material(
|
child: Material(
|
||||||
color: chatListItemColor(context, activeChat),
|
color: chatListItemColor(context, activeChat),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
|
onLongPress: () => (slideableKey.currentState as SlidableState)
|
||||||
|
.open(actionType: SlideActionType.secondary),
|
||||||
leading: Avatar(room.avatar, room.displayname),
|
leading: Avatar(room.avatar, room.displayname),
|
||||||
title: Row(
|
title: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
@ -154,21 +186,36 @@ class ChatListItem extends StatelessWidget {
|
||||||
softWrap: false,
|
softWrap: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 4),
|
room.isFavourite
|
||||||
room.pushRuleState == PushRuleState.notify
|
? Padding(
|
||||||
? Container()
|
padding: const EdgeInsets.only(left: 4.0),
|
||||||
: Icon(
|
child: Icon(
|
||||||
|
Icons.favorite,
|
||||||
|
color: Colors.grey[400],
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Container(),
|
||||||
|
isMuted
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 4.0),
|
||||||
|
child: Icon(
|
||||||
Icons.notifications_off,
|
Icons.notifications_off,
|
||||||
color: Colors.grey[400],
|
color: Colors.grey[400],
|
||||||
size: 16,
|
size: 16,
|
||||||
),
|
),
|
||||||
Text(
|
)
|
||||||
|
: Container(),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 4.0),
|
||||||
|
child: Text(
|
||||||
room.timeCreated.localizedTimeShort(context),
|
room.timeCreated.localizedTimeShort(context),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Color(0xFF555555),
|
color: Color(0xFF555555),
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
subtitle: Row(
|
subtitle: Row(
|
||||||
|
@ -224,6 +271,7 @@ class ChatListItem extends StatelessWidget {
|
||||||
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