Minor fixes
This commit is contained in:
parent
7e6212ff8a
commit
de29800f29
19 changed files with 156 additions and 104 deletions
|
|
@ -23,11 +23,13 @@ class AdaptivePageLayout extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return OrientationBuilder(builder: (context, orientation) {
|
||||
if (orientation == Orientation.portrait ||
|
||||
columnMode(context)) if (primaryPage == FocusPage.FIRST)
|
||||
return firstScaffold;
|
||||
else
|
||||
return secondScaffold;
|
||||
if (orientation == Orientation.portrait || columnMode(context)) {
|
||||
if (primaryPage == FocusPage.FIRST) {
|
||||
return firstScaffold;
|
||||
} else {
|
||||
return secondScaffold;
|
||||
}
|
||||
}
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,12 @@ class NewGroupDialog extends StatelessWidget {
|
|||
matrix.client.createRoom(params: params),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
if (roomID != null)
|
||||
Navigator.push(
|
||||
if (roomID != null) {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => Chat(roomID)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -18,11 +18,12 @@ class NewPrivateChatDialog extends StatelessWidget {
|
|||
await matrix.tryRequestWithLoadingDialog(user.startDirectChat());
|
||||
Navigator.of(context).pop();
|
||||
|
||||
if (roomID != null)
|
||||
Navigator.push(
|
||||
if (roomID != null) {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => Chat(roomID)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -22,16 +22,17 @@ class ChatListItem extends StatelessWidget {
|
|||
title: Text(room.displayname),
|
||||
subtitle: MessageContent(room.lastEvent, textOnly: true),
|
||||
onTap: () {
|
||||
if (activeChat)
|
||||
if (activeChat) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
AppRoute.defaultRoute(context, Chat(room.id)),
|
||||
);
|
||||
else
|
||||
} else {
|
||||
Navigator.push(
|
||||
context,
|
||||
AppRoute.defaultRoute(context, Chat(room.id)),
|
||||
);
|
||||
}
|
||||
},
|
||||
onLongPress: () {},
|
||||
trailing: Container(
|
||||
|
|
|
|||
|
|
@ -31,13 +31,14 @@ class Message extends StatelessWidget {
|
|||
color = event.status == -1 ? Colors.redAccent : Color(0xFF5625BA);
|
||||
}
|
||||
List<PopupMenuEntry<String>> popupMenuList = [];
|
||||
if (event.canRedact && !event.redacted && event.status > 1)
|
||||
if (event.canRedact && !event.redacted && event.status > 1) {
|
||||
popupMenuList.add(
|
||||
const PopupMenuItem<String>(
|
||||
value: "remove",
|
||||
child: Text('Remove message'),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (ownMessage && event.status == -1) {
|
||||
popupMenuList.add(
|
||||
const PopupMenuItem<String>(
|
||||
|
|
@ -59,16 +60,16 @@ class Message extends StatelessWidget {
|
|||
onSelected: (String choice) async {
|
||||
switch (choice) {
|
||||
case "remove":
|
||||
showDialog(
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => RedactMessageDialog(event),
|
||||
);
|
||||
break;
|
||||
case "resend":
|
||||
event.sendAgain();
|
||||
await event.sendAgain();
|
||||
break;
|
||||
case "delete":
|
||||
event.remove();
|
||||
await event.remove();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
|
@ -113,10 +114,11 @@ class Message extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
];
|
||||
if (ownMessage)
|
||||
if (ownMessage) {
|
||||
rowChildren.add(Avatar(event.sender.avatarUrl));
|
||||
else
|
||||
} else {
|
||||
rowChildren.insert(0, Avatar(event.sender.avatarUrl));
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
|
|
|
|||
|
|
@ -15,23 +15,23 @@ class ParticipantListItem extends StatelessWidget {
|
|||
final MatrixState matrix = Matrix.of(context);
|
||||
switch (action) {
|
||||
case "ban":
|
||||
matrix.tryRequestWithLoadingDialog(user.ban());
|
||||
await matrix.tryRequestWithLoadingDialog(user.ban());
|
||||
break;
|
||||
case "unban":
|
||||
matrix.tryRequestWithLoadingDialog(user.unban());
|
||||
await matrix.tryRequestWithLoadingDialog(user.unban());
|
||||
break;
|
||||
case "kick":
|
||||
matrix.tryRequestWithLoadingDialog(user.kick());
|
||||
await matrix.tryRequestWithLoadingDialog(user.kick());
|
||||
break;
|
||||
case "admin":
|
||||
matrix.tryRequestWithLoadingDialog(user.setPower(100));
|
||||
await matrix.tryRequestWithLoadingDialog(user.setPower(100));
|
||||
break;
|
||||
case "user":
|
||||
matrix.tryRequestWithLoadingDialog(user.setPower(100));
|
||||
await matrix.tryRequestWithLoadingDialog(user.setPower(100));
|
||||
break;
|
||||
case "message":
|
||||
final String roomId = await user.startDirectChat();
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
await Navigator.of(context).pushAndRemoveUntil(
|
||||
AppRoute.defaultRoute(
|
||||
context,
|
||||
Chat(roomId),
|
||||
|
|
@ -55,30 +55,35 @@ class ParticipantListItem extends StatelessWidget {
|
|||
List<PopupMenuEntry<String>> items = <PopupMenuEntry<String>>[];
|
||||
if (user.canChangePowerLevel &&
|
||||
user.room.ownPowerLevel == 100 &&
|
||||
user.powerLevel != 100)
|
||||
user.powerLevel != 100) {
|
||||
items.add(
|
||||
PopupMenuItem(child: Text("Make an admin"), value: "admin"),
|
||||
);
|
||||
if (user.canChangePowerLevel && user.powerLevel != 0)
|
||||
}
|
||||
if (user.canChangePowerLevel && user.powerLevel != 0) {
|
||||
items.add(
|
||||
PopupMenuItem(child: Text("Revoke all permissions"), value: "user"),
|
||||
);
|
||||
if (user.canKick)
|
||||
}
|
||||
if (user.canKick) {
|
||||
items.add(
|
||||
PopupMenuItem(child: Text("Kick from group"), value: "kick"),
|
||||
);
|
||||
if (user.canBan && user.membership != Membership.ban)
|
||||
}
|
||||
if (user.canBan && user.membership != Membership.ban) {
|
||||
items.add(
|
||||
PopupMenuItem(child: Text("Ban from group"), value: "ban"),
|
||||
);
|
||||
else if (user.canBan && user.membership == Membership.ban)
|
||||
} else if (user.canBan && user.membership == Membership.ban) {
|
||||
items.add(
|
||||
PopupMenuItem(child: Text("Remove exile"), value: "unban"),
|
||||
);
|
||||
if (user.id != Matrix.of(context).client.userID)
|
||||
}
|
||||
if (user.id != Matrix.of(context).client.userID) {
|
||||
items.add(
|
||||
PopupMenuItem(child: Text("Send a message"), value: "message"),
|
||||
);
|
||||
}
|
||||
return PopupMenuButton(
|
||||
onSelected: (action) => participantAction(context, action),
|
||||
itemBuilder: (c) => items,
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class MatrixState extends State<Matrix> {
|
|||
|
||||
final LocalStorage storage = LocalStorage('LocalStorage');
|
||||
await storage.ready;
|
||||
storage.deleteItem(widget.clientName);
|
||||
await storage.deleteItem(widget.clientName);
|
||||
}
|
||||
|
||||
BuildContext _loadingDialogContext;
|
||||
|
|
@ -128,10 +128,11 @@ class MatrixState extends State<Matrix> {
|
|||
void initState() {
|
||||
if (widget.client == null) {
|
||||
client = Client(widget.clientName, debug: false);
|
||||
if (!kIsWeb)
|
||||
if (!kIsWeb) {
|
||||
client.store = Store(client);
|
||||
else
|
||||
} else {
|
||||
loadAccount();
|
||||
}
|
||||
} else {
|
||||
client = widget.client;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class MessageContent extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final int maxLines = textOnly ? 1 : null;
|
||||
if (textOnly)
|
||||
if (textOnly) {
|
||||
return Text(
|
||||
event.getBody(),
|
||||
style: TextStyle(
|
||||
|
|
@ -23,6 +23,7 @@ class MessageContent extends StatelessWidget {
|
|||
),
|
||||
maxLines: maxLines,
|
||||
);
|
||||
}
|
||||
switch (event.type) {
|
||||
case EventTypes.Audio:
|
||||
case EventTypes.Image:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue