From 738fe48bedbceb54f69742b91041bf4d9e8c169a Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 9 Dec 2022 15:07:51 +0200 Subject: [PATCH] IconMessage should be tap to copy --- lib/ui/app/copy_to_clipboard.dart | 8 +++++++- lib/ui/app/icon_message.dart | 14 +++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/ui/app/copy_to_clipboard.dart b/lib/ui/app/copy_to_clipboard.dart index 8cc4ac527..8d3701235 100644 --- a/lib/ui/app/copy_to_clipboard.dart +++ b/lib/ui/app/copy_to_clipboard.dart @@ -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"', ), ); }; diff --git a/lib/ui/app/icon_message.dart b/lib/ui/app/icon_message.dart index dd76bce33..88b9aac3d 100644 --- a/lib/ui/app/icon_message.dart +++ b/lib/ui/app/icon_message.dart @@ -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, + ), ), ), ),