IconMessage should be tap to copy

This commit is contained in:
Hillel Coren 2022-12-09 15:07:51 +02:00
parent ddb95f6946
commit 738fe48bed
2 changed files with 16 additions and 6 deletions

View File

@ -35,10 +35,16 @@ class CopyToClipboard extends StatelessWidget {
final localization = AppLocalization.of(context);
final onTap = () {
Clipboard.setData(ClipboardData(text: value));
var valueStr = value.replaceAll('\n', ' ');
if (value.length > 20) {
valueStr = value.substring(0, 20) + '...';
}
showToast(
localization.copiedToClipboard.replaceFirst(
':value',
value.replaceAll('\n', ' '),
'"$valueStr"',
),
);
};

View File

@ -1,5 +1,6 @@
// Flutter imports:
import 'package:flutter/material.dart';
import 'package:invoiceninja_flutter/ui/app/copy_to_clipboard.dart';
class IconMessage extends StatelessWidget {
const IconMessage(
@ -29,11 +30,14 @@ class IconMessage extends StatelessWidget {
),
SizedBox(width: 16),
Expanded(
child: Text(
text,
maxLines: null,
style: TextStyle(
color: Colors.white,
child: CopyToClipboard(
value: text,
child: Text(
text,
maxLines: null,
style: TextStyle(
color: Colors.white,
),
),
),
),