Merge branch 'add-copy-function' into 'master'
Add copy function See merge request ChristianPauly/fluffychat-flutter!16
This commit is contained in:
commit
c173091ca4
|
@ -4,6 +4,7 @@ import 'package:fluffychat/components/dialogs/redact_message_dialog.dart';
|
|||
import 'package:fluffychat/components/message_content.dart';
|
||||
import 'package:fluffychat/utils/chat_time.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../avatar.dart';
|
||||
import '../matrix.dart';
|
||||
|
@ -43,6 +44,25 @@ class Message extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (!event.redacted &&
|
||||
[
|
||||
MessageTypes.Text,
|
||||
MessageTypes.Reply,
|
||||
MessageTypes.Location,
|
||||
MessageTypes.Notice,
|
||||
MessageTypes.Emote,
|
||||
MessageTypes.None,
|
||||
].contains(event.messageType) &&
|
||||
event.getBody().isNotEmpty) {
|
||||
popupMenuList.add(
|
||||
const PopupMenuItem<String>(
|
||||
value: "copy",
|
||||
child: Text('Copy'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (ownMessage && event.status == -1) {
|
||||
popupMenuList.add(
|
||||
const PopupMenuItem<String>(
|
||||
|
@ -75,6 +95,9 @@ class Message extends StatelessWidget {
|
|||
case "delete":
|
||||
await event.remove();
|
||||
break;
|
||||
case "copy":
|
||||
await Clipboard.setData(ClipboardData(text: event.getBody()));
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) => popupMenuList,
|
||||
|
|
|
@ -114,9 +114,12 @@ class MessageContent extends StatelessWidget {
|
|||
? "You: "
|
||||
: "${event.sender.calcDisplayname()}: "
|
||||
: "";
|
||||
final String body = event.redacted
|
||||
? "Redacted by ${event.redactedBecause.sender.calcDisplayname()}"
|
||||
: senderPrefix + event.getBody();
|
||||
if (textOnly) {
|
||||
return Text(
|
||||
senderPrefix + event.getBody(),
|
||||
body,
|
||||
maxLines: maxLines,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
|
@ -127,7 +130,7 @@ class MessageContent extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
return LinkText(
|
||||
text: senderPrefix + event.getBody(),
|
||||
text: body,
|
||||
textStyle: TextStyle(
|
||||
color: textColor,
|
||||
decoration: event.redacted ? TextDecoration.lineThrough : null,
|
||||
|
|
Loading…
Reference in a new issue