Skip to content

Commit

Permalink
TW-730: fix forward image not back to chat screen
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn authored and hoangdat committed Oct 5, 2023
1 parent 5ef0cd5 commit b52157d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/pages/forward/forward.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:fluffychat/pages/chat/send_file_dialog.dart';
import 'package:fluffychat/pages/forward/forward_view.dart';
import 'package:fluffychat/presentation/enum/chat_list/chat_list_enum.dart';
import 'package:fluffychat/presentation/extensions/client_extension.dart';
import 'package:fluffychat/utils/extension/navigator_state_extension.dart';
import 'package:fluffychat/presentation/model/pop_result_from_forward.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:matrix/matrix.dart';
Expand Down Expand Up @@ -107,7 +107,9 @@ class ForwardController extends State<Forward> {
switch (success.runtimeType) {
case ForwardMessageSuccess:
final dataOnSuccess = success as ForwardMessageSuccess;
Navigator.of(context).popAllDialogs();
if (Navigator.of(context).canPop()) {
Navigator.of(context).pop(const PopResultFromForward());
}
context.go('/rooms/${dataOnSuccess.room.id}');
break;
case ForwardMessageIsShareFileState:
Expand Down
6 changes: 5 additions & 1 deletion lib/pages/image_viewer/image_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:typed_data';

import 'package:fluffychat/pages/forward/forward.dart';
import 'package:fluffychat/pages/image_viewer/image_viewer_view.dart';
import 'package:fluffychat/presentation/model/pop_result_from_forward.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/event_extension.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/matrix.dart';
Expand Down Expand Up @@ -46,12 +47,15 @@ class ImageViewerController extends State<ImageViewer> {
/// Forward this image to another room.
void forwardAction() async {
Matrix.of(context).shareContent = widget.event.content;
await showDialog(
final result = await showDialog(
context: context,
useSafeArea: false,
useRootNavigator: false,
builder: (c) => const Forward(),
);
if (result is PopResultFromForward) {
Navigator.of(context).pop<PopResultFromForward>();
}
}

void toggleAppbarPreview() {
Expand Down
8 changes: 8 additions & 0 deletions lib/presentation/model/pop_result.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:equatable/equatable.dart';

class PopResult with EquatableMixin {
const PopResult();

@override
List<Object?> get props => [];
}
5 changes: 5 additions & 0 deletions lib/presentation/model/pop_result_from_forward.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:fluffychat/presentation/model/pop_result.dart';

class PopResultFromForward extends PopResult {
const PopResultFromForward();
}

0 comments on commit b52157d

Please sign in to comment.