Implement forwarding messages
This commit is contained in:
parent
bd36e3039e
commit
72dce3ac1d
|
@ -6,6 +6,7 @@ import 'package:fluffychat/utils/room_name_calculator.dart';
|
||||||
import 'package:fluffychat/views/chat.dart';
|
import 'package:fluffychat/views/chat.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:toast/toast.dart';
|
import 'package:toast/toast.dart';
|
||||||
|
import 'package:pedantic/pedantic.dart';
|
||||||
|
|
||||||
import '../avatar.dart';
|
import '../avatar.dart';
|
||||||
import '../matrix.dart';
|
import '../matrix.dart';
|
||||||
|
@ -67,6 +68,10 @@ class ChatListItem extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (room.membership == Membership.join) {
|
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(
|
await Navigator.pushAndRemoveUntil(
|
||||||
context,
|
context,
|
||||||
AppRoute.defaultRoute(context, Chat(room.id)),
|
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) {
|
if (ownMessage && event.status == -1) {
|
||||||
popupMenuList.add(
|
popupMenuList.add(
|
||||||
const PopupMenuItem<String>(
|
const PopupMenuItem<String>(
|
||||||
|
@ -108,6 +117,10 @@ class Message extends StatelessWidget {
|
||||||
case "copy":
|
case "copy":
|
||||||
await Clipboard.setData(ClipboardData(text: event.body));
|
await Clipboard.setData(ClipboardData(text: event.body));
|
||||||
break;
|
break;
|
||||||
|
case "forward":
|
||||||
|
Matrix.of(context).shareContent = event.content;
|
||||||
|
Navigator.of(context).popUntil((r) => r.isFirst);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
itemBuilder: (BuildContext context) => popupMenuList,
|
itemBuilder: (BuildContext context) => popupMenuList,
|
||||||
|
|
|
@ -42,6 +42,7 @@ class MatrixState extends State<Matrix> {
|
||||||
FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
||||||
FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
|
FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
|
||||||
FlutterLocalNotificationsPlugin();
|
FlutterLocalNotificationsPlugin();
|
||||||
|
Map<String, dynamic> shareContent;
|
||||||
|
|
||||||
String activeRoomId;
|
String activeRoomId;
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ import 'package:fluffychat/views/settings.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
|
|
||||||
|
enum SelectMode { normal, multi_select, share }
|
||||||
|
|
||||||
class ChatListView extends StatelessWidget {
|
class ChatListView extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -39,6 +41,7 @@ class _ChatListState extends State<ChatList> {
|
||||||
bool searchMode = false;
|
bool searchMode = false;
|
||||||
StreamSubscription sub;
|
StreamSubscription sub;
|
||||||
final TextEditingController searchController = TextEditingController();
|
final TextEditingController searchController = TextEditingController();
|
||||||
|
SelectMode selectMode = SelectMode.normal;
|
||||||
|
|
||||||
Future<bool> waitForFirstSync(BuildContext context) async {
|
Future<bool> waitForFirstSync(BuildContext context) async {
|
||||||
Client client = Matrix.of(context).client;
|
Client client = Matrix.of(context).client;
|
||||||
|
@ -68,6 +71,11 @@ class _ChatListState extends State<ChatList> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
if (Matrix.of(context).shareContent != null) {
|
||||||
|
selectMode = SelectMode.share;
|
||||||
|
} else if (selectMode == SelectMode.share) {
|
||||||
|
setState(() => selectMode = SelectMode.normal);
|
||||||
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: searchMode
|
title: searchMode
|
||||||
|
@ -81,7 +89,7 @@ class _ChatListState extends State<ChatList> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Text(
|
: Text(
|
||||||
"FluffyChat",
|
selectMode == SelectMode.share ? "Share" : "FluffyChat",
|
||||||
),
|
),
|
||||||
leading: searchMode
|
leading: searchMode
|
||||||
? IconButton(
|
? IconButton(
|
||||||
|
@ -97,6 +105,15 @@ class _ChatListState extends State<ChatList> {
|
||||||
icon: Icon(Icons.search),
|
icon: Icon(Icons.search),
|
||||||
onPressed: () => setState(() => searchMode = true),
|
onPressed: () => setState(() => searchMode = true),
|
||||||
),
|
),
|
||||||
|
if (selectMode == SelectMode.share)
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.close),
|
||||||
|
onPressed: () {
|
||||||
|
Matrix.of(context).shareContent = null;
|
||||||
|
setState(() => selectMode = SelectMode.normal);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (selectMode == SelectMode.normal)
|
||||||
PopupMenuButton(
|
PopupMenuButton(
|
||||||
onSelected: (String choice) {
|
onSelected: (String choice) {
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
|
|
Loading…
Reference in a new issue