mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-19 10:39:26 +01:00
Add copy function
This commit is contained in:
parent
921d0984ee
commit
0fd90af759
@ -4,6 +4,7 @@ import 'package:fluffychat/components/dialogs/redact_message_dialog.dart';
|
|||||||
import 'package:fluffychat/components/message_content.dart';
|
import 'package:fluffychat/components/message_content.dart';
|
||||||
import 'package:fluffychat/utils/chat_time.dart';
|
import 'package:fluffychat/utils/chat_time.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import '../avatar.dart';
|
import '../avatar.dart';
|
||||||
import '../matrix.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) {
|
if (ownMessage && event.status == -1) {
|
||||||
popupMenuList.add(
|
popupMenuList.add(
|
||||||
const PopupMenuItem<String>(
|
const PopupMenuItem<String>(
|
||||||
@ -75,6 +95,9 @@ class Message extends StatelessWidget {
|
|||||||
case "delete":
|
case "delete":
|
||||||
await event.remove();
|
await event.remove();
|
||||||
break;
|
break;
|
||||||
|
case "copy":
|
||||||
|
await Clipboard.setData(ClipboardData(text: event.getBody()));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
itemBuilder: (BuildContext context) => popupMenuList,
|
itemBuilder: (BuildContext context) => popupMenuList,
|
||||||
|
@ -114,9 +114,12 @@ class MessageContent extends StatelessWidget {
|
|||||||
? "You: "
|
? "You: "
|
||||||
: "${event.sender.calcDisplayname()}: "
|
: "${event.sender.calcDisplayname()}: "
|
||||||
: "";
|
: "";
|
||||||
|
final String body = event.redacted
|
||||||
|
? "Redacted by ${event.redactedBecause.sender.calcDisplayname()}"
|
||||||
|
: senderPrefix + event.getBody();
|
||||||
if (textOnly) {
|
if (textOnly) {
|
||||||
return Text(
|
return Text(
|
||||||
senderPrefix + event.getBody(),
|
body,
|
||||||
maxLines: maxLines,
|
maxLines: maxLines,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@ -127,7 +130,7 @@ class MessageContent extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return LinkText(
|
return LinkText(
|
||||||
text: senderPrefix + event.getBody(),
|
text: body,
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(
|
||||||
color: textColor,
|
color: textColor,
|
||||||
decoration: event.redacted ? TextDecoration.lineThrough : null,
|
decoration: event.redacted ? TextDecoration.lineThrough : null,
|
||||||
|
Loading…
Reference in New Issue
Block a user