From d3064a356f124750ac8ef1e4b4a9a8d9e9427573 Mon Sep 17 00:00:00 2001 From: HuyNguyen Date: Tue, 17 Dec 2024 15:07:45 +0700 Subject: [PATCH 1/2] TW-2103: Improve redirection after forwarding media --- assets/l10n/intl_en.arb | 9 ++++++++- lib/pages/chat/chat.dart | 7 ++++++- lib/pages/forward/forward.dart | 7 +++++-- .../mixins/media_viewer_app_bar_mixin.dart | 12 ++++++++---- lib/presentation/model/pop_result_from_forward.dart | 7 ++++++- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 3fe674e8e2..12883c0146 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -3102,5 +3102,12 @@ "thisFieldCannotBeBlank": "This field cannot be blank", "deleteAccountMessage": "Groups chats that you have created will remain unadministered unless you have given another user administrator rights. Users will still have a history of messages with you. Deleting the account won't help.", "deleteLater": "Delete later", - "areYouSureYouWantToDeleteAccount": "Are you sure you want to delete account?" + "areYouSureYouWantToDeleteAccount": "Are you sure you want to delete account?", + "messageForwardedTo": "Message forwarded to {roomName}", + "@messageForwardedTo": { + "type": "text", + "placeholders": { + "roomName": {} + } + } } diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index e4a8c83925..ed08cd87bf 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -9,6 +9,7 @@ import 'package:fluffychat/presentation/mixins/paste_image_mixin.dart'; import 'package:fluffychat/presentation/mixins/save_media_to_gallery_android_mixin.dart'; import 'package:fluffychat/presentation/mixins/save_file_to_twake_downloads_folder_mixin.dart'; import 'package:fluffychat/presentation/model/chat/view_event_list_ui_state.dart'; +import 'package:fluffychat/presentation/model/pop_result_from_forward.dart'; import 'package:fluffychat/utils/extension/basic_event_extension.dart'; import 'package:fluffychat/utils/extension/event_status_custom_extension.dart'; import 'package:fluffychat/utils/manager/upload_manager/upload_manager.dart'; @@ -838,12 +839,16 @@ class ChatController extends State ); } _clearSelectEvent(); - context.push( + final result = await context.push( '/rooms/forward', extra: ForwardArgument( fromRoomId: roomId ?? '', ), ); + + if (result != null) { + context.go('/rooms/${result.roomReceiver.id}'); + } } void sendAgainAction() { diff --git a/lib/pages/forward/forward.dart b/lib/pages/forward/forward.dart index 36824763de..c5433d8bc7 100644 --- a/lib/pages/forward/forward.dart +++ b/lib/pages/forward/forward.dart @@ -125,9 +125,12 @@ class ForwardController extends State case const (ForwardMessageSuccess): final dataOnSuccess = success as ForwardMessageSuccess; if (Navigator.of(context).canPop()) { - Navigator.of(context).pop(const PopResultFromForward()); + Navigator.of(context).pop( + PopResultFromForward( + roomReceiver: dataOnSuccess.room, + ), + ); } - context.go('/rooms/${dataOnSuccess.room.id}'); break; case const (ForwardMessageIsShareFileState): final dataOnSuccess = success as ForwardMessageIsShareFileState; diff --git a/lib/presentation/mixins/media_viewer_app_bar_mixin.dart b/lib/presentation/mixins/media_viewer_app_bar_mixin.dart index 9bd069b01f..528d5810aa 100644 --- a/lib/presentation/mixins/media_viewer_app_bar_mixin.dart +++ b/lib/presentation/mixins/media_viewer_app_bar_mixin.dart @@ -7,11 +7,13 @@ import 'package:fluffychat/presentation/model/pop_result_from_forward.dart'; import 'package:fluffychat/utils/extension/build_context_extension.dart'; import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/responsive/responsive_utils.dart'; +import 'package:fluffychat/utils/twake_snackbar.dart'; import 'package:fluffychat/widgets/matrix.dart'; import 'package:flutter/material.dart'; import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart'; import 'package:matrix/matrix.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/event_extension.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; mixin MediaViewerAppBarMixin on SaveMediaToGalleryAndroidMixin { final MenuController menuController = MenuController(); @@ -37,10 +39,12 @@ mixin MediaViewerAppBarMixin on SaveMediaToGalleryAndroidMixin { final result = responsive.isMobile(context) ? await _showForwardMobileDialog(context) : await _showForwardWebDialog(context); - - if (result is PopResultFromForward) { - Navigator.of(context).pop(); - } + TwakeSnackBar.show( + context, + L10n.of(context)!.messageForwardedTo( + result?.roomReceiver.getLocalizedDisplayname() ?? '', + ), + ); } Future _showForwardMobileDialog( diff --git a/lib/presentation/model/pop_result_from_forward.dart b/lib/presentation/model/pop_result_from_forward.dart index 3e93417ab7..ba53fe3d0b 100644 --- a/lib/presentation/model/pop_result_from_forward.dart +++ b/lib/presentation/model/pop_result_from_forward.dart @@ -1,5 +1,10 @@ import 'package:fluffychat/presentation/model/pop_result.dart'; +import 'package:matrix/matrix.dart'; class PopResultFromForward extends PopResult { - const PopResultFromForward(); + final Room roomReceiver; + + const PopResultFromForward({ + required this.roomReceiver, + }); } From f90dfd7c2525c6ce5779beabf442fbcc66a92640 Mon Sep 17 00:00:00 2001 From: HuyNguyen Date: Tue, 17 Dec 2024 16:15:07 +0700 Subject: [PATCH 2/2] fixup! TW-2103: Improve redirection after forwarding media --- lib/presentation/mixins/media_viewer_app_bar_mixin.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/presentation/mixins/media_viewer_app_bar_mixin.dart b/lib/presentation/mixins/media_viewer_app_bar_mixin.dart index 528d5810aa..3162f05f83 100644 --- a/lib/presentation/mixins/media_viewer_app_bar_mixin.dart +++ b/lib/presentation/mixins/media_viewer_app_bar_mixin.dart @@ -68,7 +68,6 @@ mixin MediaViewerAppBarMixin on SaveMediaToGalleryAndroidMixin { ) async => await showDialog( context: context, - barrierDismissible: false, useSafeArea: false, useRootNavigator: false, builder: (context) {