diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 353097a77d..87b82bd8b8 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2764,5 +2764,7 @@ "paste": "Paste", "cut": "Cut", "pasteImageFailed": "Paste image failed", - "copyImageFailed": "Copy image failed" + "copyImageFailed": "Copy image failed", + "fileFormatNotSupported": "File format not supported", + "copyImageSuccess": "Copy image success" } \ No newline at end of file diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index 3e3c95e36c..2e33517e2a 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -787,15 +787,21 @@ class ChatController extends State ); if (event.messageType == MessageTypes.Image) { if (matrixFile.filePath != null) { - Clipboard.instance.copyImageAsStream( + await Clipboard.instance.copyImageAsStream( File(matrixFile.filePath!), mimeType: event.mimeType, ); + if (!PlatformInfos.isAndroid) { + TwakeSnackBar.show(context, L10n.of(context)!.copyImageSuccess); + } } else if (matrixFile.bytes != null) { - Clipboard.instance.copyImageAsBytes( + await Clipboard.instance.copyImageAsBytes( matrixFile.bytes!, mimeType: event.mimeType, ); + if (!PlatformInfos.isAndroid) { + TwakeSnackBar.show(context, L10n.of(context)!.copyImageSuccess); + } } else { TwakeSnackBar.show(context, L10n.of(context)!.copyImageFailed); Logs().e( diff --git a/lib/pages/chat/input_bar.dart b/lib/pages/chat/input_bar.dart index 6f3fa26fcd..1143a471d3 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -461,7 +461,7 @@ class InputBar extends StatelessWidget with PasteImageMixin { // FIXME: need to handle the case when in draft chat return; } - + await Clipboard.instance.initReader(); if (await Clipboard.instance .isReadableImageFormat()) { await pasteImage(context, room!); diff --git a/lib/pages/chat/send_file_dialog.dart b/lib/pages/chat/send_file_dialog.dart index 42bf1949e9..33893a16d7 100644 --- a/lib/pages/chat/send_file_dialog.dart +++ b/lib/pages/chat/send_file_dialog.dart @@ -1,3 +1,5 @@ +import 'package:fluffychat/presentation/extensions/send_file_web_extension.dart'; +import 'package:fluffychat/utils/localized_exception_extension.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -43,18 +45,18 @@ class SendFileDialogState extends State { } // ignore: unused_local_variable final scaffoldMessenger = ScaffoldMessenger.of(context); - // widget.room - // .sendFileEvent( - // file, - // thumbnail: thumbnail, - // shrinkImageMaxDimension: origImage ? null : 1600, - // ) - // .catchError((e) { - // scaffoldMessenger.showSnackBar( - // SnackBar(content: Text((e as Object).toLocalizedString(context))), - // ); - // return null; - // }); + widget.room + .sendFileOnWebEvent( + file, + thumbnail: thumbnail, + shrinkImageMaxDimension: origImage ? null : 1600, + ) + .catchError((e) { + scaffoldMessenger.showSnackBar( + SnackBar(content: Text((e as Object).toLocalizedString(context))), + ); + return null; + }); } Navigator.of(context, rootNavigator: false).pop(); diff --git a/lib/presentation/mixins/paste_image_mixin.dart b/lib/presentation/mixins/paste_image_mixin.dart index 3444b02b9e..e2271c79ba 100644 --- a/lib/presentation/mixins/paste_image_mixin.dart +++ b/lib/presentation/mixins/paste_image_mixin.dart @@ -13,6 +13,7 @@ mixin PasteImageMixin { Future pasteImage(BuildContext context, Room room) async { await Clipboard.instance.initReader(); if (!(await Clipboard.instance.isReadableImageFormat())) { + TwakeSnackBar.show(context, L10n.of(context)!.fileFormatNotSupported); Logs().e('PasteImageMixin::pasteImage(): not readable image format'); return; }