fluffychat/lib/pages/image_viewer.dart

43 lines
1.3 KiB
Dart
Raw Normal View History

import 'package:matrix/matrix.dart';
2021-04-10 09:06:24 +02:00
import 'package:fluffychat/utils/platform_infos.dart';
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
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
}
2021-07-11 17:12:56 +02:00
/// Save this file with a system call.
void saveFileAction() => widget.event.saveFile(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
}