mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-28 07:19:32 +01:00
a9275fc4f6
- defaultly save files on Android instead of share - add dedicated share button for files and images on Android - use ListTile instead of row to display file event - update file_picker_cross Signed-off-by: TheOneWithTheBraid <the-one@with-the-braid.cf>
49 lines
1.5 KiB
Dart
49 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
import 'package:vrouter/vrouter.dart';
|
|
|
|
import 'package:fluffychat/pages/image_viewer/image_viewer_view.dart';
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
|
import '../../utils/matrix_sdk_extensions.dart/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;
|
|
VRouter.of(context).to('/rooms');
|
|
}
|
|
|
|
/// Save this file with a system call.
|
|
void saveFileAction() => widget.event.saveFile(context);
|
|
|
|
/// Save this file with a system call.
|
|
void shareFileAction() => 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);
|
|
}
|