diff --git a/lib/pages/image_viewer.dart b/lib/pages/image_viewer.dart index eba2a46d..20fba498 100644 --- a/lib/pages/image_viewer.dart +++ b/lib/pages/image_viewer.dart @@ -25,7 +25,7 @@ class ImageViewerController extends State { } /// Open this file with a system call. - void openFileAction() => widget.event.openFile(context, downloadOnly: true); + void openFileAction() => widget.event.openFile(context); /// Go back if user swiped it away void onInteractionEnds(ScaleEndDetails endDetails) { diff --git a/lib/utils/matrix_sdk_extensions.dart/event_extension.dart b/lib/utils/matrix_sdk_extensions.dart/event_extension.dart index bf525844..396384f7 100644 --- a/lib/utils/matrix_sdk_extensions.dart/event_extension.dart +++ b/lib/utils/matrix_sdk_extensions.dart/event_extension.dart @@ -4,18 +4,9 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'matrix_file_extension.dart'; -import '../../pages/image_viewer.dart'; -import '../../widgets/matrix.dart'; extension LocalizedBody on Event { - void openFile(BuildContext context, {bool downloadOnly = false}) async { - if (!downloadOnly && - [MessageTypes.Image, MessageTypes.Sticker].contains(messageType)) { - await Navigator.of(Matrix.of(context).navigatorContext).push( - MaterialPageRoute(builder: (_) => ImageViewer(this)), - ); - return; - } + void openFile(BuildContext context) async { final matrixFile = await showFutureLoadingDialog( context: context, future: () => downloadAndDecryptAttachmentCached(), diff --git a/lib/widgets/event_content/image_bubble.dart b/lib/widgets/event_content/image_bubble.dart index 8198edaa..8742d1eb 100644 --- a/lib/widgets/event_content/image_bubble.dart +++ b/lib/widgets/event_content/image_bubble.dart @@ -7,7 +7,6 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter_svg/flutter_svg.dart'; import '../../utils/matrix_sdk_extensions.dart/event_extension.dart'; -import '../matrix.dart'; class ImageBubble extends StatefulWidget { final Event event; @@ -238,22 +237,21 @@ class _ImageBubbleState extends State { child: InkWell( onTap: () { if (!widget.tapToView) return; - Navigator.of(Matrix.of(context).navigatorContext).push( - MaterialPageRoute( - builder: (_) => ImageViewer(widget.event, onLoaded: () { - // If the original file didn't load yet, we want to do that now. - // This is so that the original file displays after going on the image viewer, - // waiting for it to load, and then hitting back. This ensures that we always - // display the best image available, with requiring as little network as possible - if (_file == null) { - widget.event.isAttachmentCached().then((cached) { - if (cached) { - _requestFile(); - } - }); - } - }), - ), + showDialog( + context: context, + builder: (_) => ImageViewer(widget.event, onLoaded: () { + // If the original file didn't load yet, we want to do that now. + // This is so that the original file displays after going on the image viewer, + // waiting for it to load, and then hitting back. This ensures that we always + // display the best image available, with requiring as little network as possible + if (_file == null) { + widget.event.isAttachmentCached().then((cached) { + if (cached) { + _requestFile(); + } + }); + } + }), ); }, child: Hero(