Skip to content

Commit

Permalink
TW-2103: Improve redirection after forwarding media
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev committed Dec 17, 2024
1 parent 01e908e commit d3064a3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
9 changes: 8 additions & 1 deletion assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {}
}
}
}
7 changes: 6 additions & 1 deletion lib/pages/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -838,12 +839,16 @@ class ChatController extends State<Chat>
);
}
_clearSelectEvent();
context.push(
final result = await context.push<PopResultFromForward>(
'/rooms/forward',
extra: ForwardArgument(
fromRoomId: roomId ?? '',
),
);

if (result != null) {
context.go('/rooms/${result.roomReceiver.id}');
}
}

void sendAgainAction() {
Expand Down
7 changes: 5 additions & 2 deletions lib/pages/forward/forward.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,12 @@ class ForwardController extends State<Forward>
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;
Expand Down
12 changes: 8 additions & 4 deletions lib/presentation/mixins/media_viewer_app_bar_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<PopResultFromForward>();
}
TwakeSnackBar.show(
context,
L10n.of(context)!.messageForwardedTo(
result?.roomReceiver.getLocalizedDisplayname() ?? '',
),
);
}

Future<PopResultFromForward?> _showForwardMobileDialog(
Expand Down
7 changes: 6 additions & 1 deletion lib/presentation/model/pop_result_from_forward.dart
Original file line number Diff line number Diff line change
@@ -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,
});
}

0 comments on commit d3064a3

Please sign in to comment.