Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-2103: Improve redirection after forwarding media #2193

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 8 additions & 5 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 All @@ -64,7 +68,6 @@ mixin MediaViewerAppBarMixin on SaveMediaToGalleryAndroidMixin {
) async =>
await showDialog(
context: context,
barrierDismissible: false,
useSafeArea: false,
useRootNavigator: false,
builder: (context) {
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,
});
}
Loading