2023-11-11 05:54:47 -04:00
|
|
|
import 'dart:io';
|
|
|
|
|
2023-11-10 19:34:17 -04:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
2023-10-03 13:00:59 -04:00
|
|
|
import 'package:recon/models/message.dart';
|
|
|
|
import 'package:recon/widgets/formatted_text.dart';
|
|
|
|
import 'package:recon/widgets/messages/message_state_indicator.dart';
|
2023-05-15 09:45:41 -04:00
|
|
|
|
|
|
|
class MessageText extends StatelessWidget {
|
|
|
|
const MessageText({required this.message, this.foregroundColor, super.key});
|
|
|
|
|
|
|
|
final Message message;
|
|
|
|
final Color? foregroundColor;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-11-11 05:51:24 -04:00
|
|
|
return InkWell(
|
|
|
|
borderRadius: BorderRadius.circular(16),
|
2023-11-10 19:34:17 -04:00
|
|
|
onLongPress: () async {
|
2023-11-11 05:20:55 -04:00
|
|
|
await Clipboard.setData(ClipboardData(text: message.content));
|
|
|
|
if (context.mounted) {
|
2023-11-11 05:54:47 -04:00
|
|
|
const content = Text("Copied to clipboard");
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
Platform.isIOS
|
|
|
|
? const SnackBar(content: content)
|
|
|
|
: SnackBar(
|
|
|
|
content: content,
|
|
|
|
behavior: SnackBarBehavior.floating,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(16),
|
|
|
|
),
|
|
|
|
dismissDirection: DismissDirection.none,
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
bottom: MediaQuery.of(context).size.height - 170,
|
|
|
|
right: 20,
|
|
|
|
left: 20,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2023-11-11 05:20:55 -04:00
|
|
|
}
|
2023-11-10 19:34:17 -04:00
|
|
|
},
|
|
|
|
child: Column(
|
2023-05-15 09:45:41 -04:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
constraints: const BoxConstraints(maxWidth: 300),
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
|
|
child: FormattedText(
|
|
|
|
message.formattedContent,
|
|
|
|
softWrap: true,
|
|
|
|
maxLines: null,
|
2023-11-11 06:03:14 -04:00
|
|
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(color: foregroundColor),
|
2023-05-15 09:45:41 -04:00
|
|
|
),
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
children: [
|
2023-11-10 19:34:17 -04:00
|
|
|
MessageStateIndicator(
|
|
|
|
message: message,
|
|
|
|
foregroundColor: foregroundColor,
|
|
|
|
),
|
2023-05-15 09:45:41 -04:00
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2023-11-10 19:34:17 -04:00
|
|
|
),
|
2023-05-15 09:45:41 -04:00
|
|
|
);
|
|
|
|
}
|
2023-11-10 19:34:17 -04:00
|
|
|
}
|