You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.6 KiB
Dart
51 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
import 'package:fluffychat/pages/image_viewer/image_viewer_view.dart';
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
|
import 'package:fluffychat/utils/show_scaffold_dialog.dart';
|
|
import 'package:fluffychat/widgets/share_scaffold_dialog.dart';
|
|
import '../../utils/matrix_sdk_extensions/event_extension.dart';
|
|
|
|
class ImageViewer extends StatefulWidget {
|
|
final Event event;
|
|
final BuildContext outerContext;
|
|
|
|
const ImageViewer(this.event, {required this.outerContext, super.key});
|
|
|
|
@override
|
|
ImageViewerController createState() => ImageViewerController();
|
|
}
|
|
|
|
class ImageViewerController extends State<ImageViewer> {
|
|
/// Forward this image to another room.
|
|
void forwardAction() => showScaffoldDialog(
|
|
context: context,
|
|
builder: (context) => ShareScaffoldDialog(
|
|
items: [ContentShareItem(widget.event.content)],
|
|
),
|
|
);
|
|
|
|
/// Save this file with a system call.
|
|
void saveFileAction(BuildContext context) => widget.event.saveFile(context);
|
|
|
|
/// Save this file with a system call.
|
|
void shareFileAction(BuildContext context) => widget.event.shareFile(context);
|
|
|
|
static const maxScaleFactor = 1.5;
|
|
|
|
/// 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 * maxScaleFactor) {
|
|
Navigator.of(context, rootNavigator: false).pop();
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) => ImageViewerView(this);
|
|
}
|