fix: Image viewer routing

This commit is contained in:
Christian Pauly 2021-06-06 10:09:13 +02:00
parent 2b83e69c1f
commit 7d6cbeec26
3 changed files with 17 additions and 28 deletions

View File

@ -25,7 +25,7 @@ class ImageViewerController extends State<ImageViewer> {
}
/// 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) {

View File

@ -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(),

View File

@ -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,8 +237,8 @@ class _ImageBubbleState extends State<ImageBubble> {
child: InkWell(
onTap: () {
if (!widget.tapToView) return;
Navigator.of(Matrix.of(context).navigatorContext).push(
MaterialPageRoute(
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,
@ -253,7 +252,6 @@ class _ImageBubbleState extends State<ImageBubble> {
});
}
}),
),
);
},
child: Hero(