Implement forwarding messages
This commit is contained in:
parent
bd36e3039e
commit
72dce3ac1d
4 changed files with 72 additions and 36 deletions
|
|
@ -6,6 +6,7 @@ import 'package:fluffychat/utils/room_name_calculator.dart';
|
|||
import 'package:fluffychat/views/chat.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
import 'package:pedantic/pedantic.dart';
|
||||
|
||||
import '../avatar.dart';
|
||||
import '../matrix.dart';
|
||||
|
|
@ -67,6 +68,10 @@ class ChatListItem extends StatelessWidget {
|
|||
}
|
||||
|
||||
if (room.membership == Membership.join) {
|
||||
if (Matrix.of(context).shareContent != null) {
|
||||
unawaited(room.sendEvent(Matrix.of(context).shareContent));
|
||||
Matrix.of(context).shareContent = null;
|
||||
}
|
||||
await Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
AppRoute.defaultRoute(context, Chat(room.id)),
|
||||
|
|
|
|||
|
|
@ -72,6 +72,15 @@ class Message extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
if (!event.redacted) {
|
||||
popupMenuList.add(
|
||||
const PopupMenuItem<String>(
|
||||
value: "forward",
|
||||
child: Text('Forward'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (ownMessage && event.status == -1) {
|
||||
popupMenuList.add(
|
||||
const PopupMenuItem<String>(
|
||||
|
|
@ -108,6 +117,10 @@ class Message extends StatelessWidget {
|
|||
case "copy":
|
||||
await Clipboard.setData(ClipboardData(text: event.body));
|
||||
break;
|
||||
case "forward":
|
||||
Matrix.of(context).shareContent = event.content;
|
||||
Navigator.of(context).popUntil((r) => r.isFirst);
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) => popupMenuList,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ class MatrixState extends State<Matrix> {
|
|||
FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
||||
FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
Map<String, dynamic> shareContent;
|
||||
|
||||
String activeRoomId;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue