feat: add copying message text via long press
This commit is contained in:
parent
af43af673d
commit
393d71a8bc
1 changed files with 17 additions and 6 deletions
|
@ -1,7 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:recon/models/message.dart';
|
||||
import 'package:recon/widgets/formatted_text.dart';
|
||||
import 'package:recon/widgets/messages/message_state_indicator.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MessageText extends StatelessWidget {
|
||||
const MessageText({required this.message, this.foregroundColor, super.key});
|
||||
|
@ -11,7 +12,14 @@ class MessageText extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
return GestureDetector(
|
||||
onLongPress: () async {
|
||||
await Clipboard.setData(ClipboardData(text: message.content)).then((_) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text("Copied to clipboard")));
|
||||
});
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Container(
|
||||
|
@ -21,8 +29,7 @@ class MessageText extends StatelessWidget {
|
|||
message.formattedContent,
|
||||
softWrap: true,
|
||||
maxLines: null,
|
||||
style: Theme
|
||||
.of(context)
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyLarge
|
||||
?.copyWith(color: foregroundColor),
|
||||
|
@ -32,10 +39,14 @@ class MessageText extends StatelessWidget {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
MessageStateIndicator(message: message, foregroundColor: foregroundColor,),
|
||||
MessageStateIndicator(
|
||||
message: message,
|
||||
foregroundColor: foregroundColor,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue