Minor fixes
This commit is contained in:
parent
7e6212ff8a
commit
de29800f29
19 changed files with 156 additions and 104 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/chat_details.dart';
|
||||
|
|
@ -6,16 +8,37 @@ import 'package:flutter/material.dart';
|
|||
|
||||
import 'matrix.dart';
|
||||
|
||||
class ChatSettingsPopupMenu extends StatelessWidget {
|
||||
class ChatSettingsPopupMenu extends StatefulWidget {
|
||||
final Room room;
|
||||
final bool displayChatDetails;
|
||||
const ChatSettingsPopupMenu(this.room, this.displayChatDetails, {Key key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_ChatSettingsPopupMenuState createState() => _ChatSettingsPopupMenuState();
|
||||
}
|
||||
|
||||
class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
||||
StreamSubscription notificationChangeSub;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
notificationChangeSub?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
notificationChangeSub ??= Matrix.of(context)
|
||||
.client
|
||||
.onUserEvent
|
||||
.stream
|
||||
.where((u) => u.type == 'account_data' && u.eventType == "m.push_rules")
|
||||
.listen(
|
||||
(u) => setState(() => null),
|
||||
);
|
||||
List<PopupMenuEntry<String>> items = <PopupMenuEntry<String>>[
|
||||
room.pushRuleState == PushRuleState.notify
|
||||
widget.room.pushRuleState == PushRuleState.notify
|
||||
? const PopupMenuItem<String>(
|
||||
value: "mute",
|
||||
child: Text('Mute chat'),
|
||||
|
|
@ -29,7 +52,7 @@ class ChatSettingsPopupMenu extends StatelessWidget {
|
|||
child: Text('Leave'),
|
||||
),
|
||||
];
|
||||
if (displayChatDetails)
|
||||
if (widget.displayChatDetails) {
|
||||
items.insert(
|
||||
0,
|
||||
const PopupMenuItem<String>(
|
||||
|
|
@ -37,28 +60,30 @@ class ChatSettingsPopupMenu extends StatelessWidget {
|
|||
child: Text('Chat details'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return PopupMenuButton(
|
||||
onSelected: (String choice) async {
|
||||
switch (choice) {
|
||||
case "leave":
|
||||
await Matrix.of(context).tryRequestWithLoadingDialog(room.leave());
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
await Matrix.of(context)
|
||||
.tryRequestWithLoadingDialog(widget.room.leave());
|
||||
await Navigator.of(context).pushAndRemoveUntil(
|
||||
AppRoute.defaultRoute(context, ChatListView()),
|
||||
(Route r) => false);
|
||||
break;
|
||||
case "mute":
|
||||
await Matrix.of(context).tryRequestWithLoadingDialog(
|
||||
room.setPushRuleState(PushRuleState.mentions_only));
|
||||
widget.room.setPushRuleState(PushRuleState.mentions_only));
|
||||
break;
|
||||
case "unmute":
|
||||
await Matrix.of(context).tryRequestWithLoadingDialog(
|
||||
room.setPushRuleState(PushRuleState.notify));
|
||||
widget.room.setPushRuleState(PushRuleState.notify));
|
||||
break;
|
||||
case "details":
|
||||
Navigator.of(context).push(
|
||||
await Navigator.of(context).push(
|
||||
AppRoute.defaultRoute(
|
||||
context,
|
||||
ChatDetails(room),
|
||||
ChatDetails(widget.room),
|
||||
),
|
||||
);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue