fluffychat/lib/pages/image_viewer.dart

43 lines
1.4 KiB
Dart
Raw Normal View History

2021-04-10 09:06:24 +02:00
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:famedlysdk/famedlysdk.dart';
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';
import '../utils/event_extension.dart';
class ImageViewer extends StatefulWidget {
final Event event;
final void Function() onLoaded;
const ImageViewer(this.event, {Key key, this.onLoaded}) : super(key: key);
@override
ImageViewerController createState() => ImageViewerController();
}
class ImageViewerController extends State<ImageViewer> {
/// Forward this image to another room.
void forwardAction() {
Matrix.of(context).shareContent = widget.event.content;
AdaptivePageLayout.of(context).popUntilIsFirst();
}
/// Open this file with a system call.
void openFileAction() => widget.event.openFile(context, downloadOnly: true);
/// 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
}