2021-06-18 10:29:48 +02:00
|
|
|
import 'package:matrix/matrix.dart';
|
2021-04-10 09:06:24 +02:00
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
2021-05-22 09:08:23 +02:00
|
|
|
import 'package:fluffychat/pages/views/image_viewer_view.dart';
|
2021-05-22 08:53:52 +02:00
|
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
2021-04-10 09:06:24 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2021-05-23 13:11:55 +02:00
|
|
|
import 'package:vrouter/vrouter.dart';
|
2021-04-10 09:06:24 +02:00
|
|
|
|
2021-05-22 09:24:39 +02:00
|
|
|
import '../utils/matrix_sdk_extensions.dart/event_extension.dart';
|
2021-04-10 09:06:24 +02:00
|
|
|
|
|
|
|
class ImageViewer extends StatefulWidget {
|
2021-05-25 20:41:37 +02:00
|
|
|
final Event event;
|
2021-04-10 09:06:24 +02:00
|
|
|
final void Function() onLoaded;
|
|
|
|
|
2021-05-25 20:41:37 +02:00
|
|
|
const ImageViewer(this.event, {Key key, this.onLoaded}) : super(key: key);
|
2021-04-10 09:06:24 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
ImageViewerController createState() => ImageViewerController();
|
|
|
|
}
|
|
|
|
|
|
|
|
class ImageViewerController extends State<ImageViewer> {
|
|
|
|
/// Forward this image to another room.
|
2021-05-25 20:41:37 +02:00
|
|
|
void forwardAction() {
|
|
|
|
Matrix.of(context).shareContent = widget.event.content;
|
2021-07-08 17:10:20 +02:00
|
|
|
VRouter.of(context).to('/rooms');
|
2021-04-10 09:06:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Open this file with a system call.
|
2021-06-06 10:09:13 +02:00
|
|
|
void openFileAction() => widget.event.openFile(context);
|
2021-04-10 09:06:24 +02:00
|
|
|
|
|
|
|
/// Go back if user swiped it away
|
|
|
|
void onInteractionEnds(ScaleEndDetails endDetails) {
|
|
|
|
if (PlatformInfos.usesTouchscreen == false) {
|
|
|
|
if (endDetails.velocity.pixelsPerSecond.dy >
|
|
|
|
MediaQuery.of(context).size.height * 1.50) {
|
|
|
|
Navigator.of(context, rootNavigator: false).pop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2021-05-22 09:13:47 +02:00
|
|
|
Widget build(BuildContext context) => ImageViewerView(this);
|
2021-04-10 09:06:24 +02:00
|
|
|
}
|