fluffychat/lib/pages/image_viewer/image_viewer_view.dart

72 lines
2.2 KiB
Dart
Raw Normal View History

2020-05-16 08:02:33 +02:00
import 'package:flutter/material.dart';
2021-10-26 18:50:34 +02:00
2021-02-20 07:40:42 +01:00
import 'package:flutter_gen/gen_l10n/l10n.dart';
2020-05-16 08:02:33 +02:00
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/mxc_image.dart';
2021-11-09 21:32:16 +01:00
import 'image_viewer.dart';
2021-10-26 18:50:34 +02:00
2021-05-22 09:13:47 +02:00
class ImageViewerView extends StatelessWidget {
2021-04-10 09:06:24 +02:00
final ImageViewerController controller;
2020-05-16 08:02:33 +02:00
2022-01-29 12:35:03 +01:00
const ImageViewerView(this.controller, {Key? key}) : super(key: key);
2020-05-16 08:02:33 +02:00
@override
Widget build(BuildContext context) {
2021-05-25 20:41:37 +02:00
return Scaffold(
backgroundColor: Colors.black,
extendBodyBehindAppBar: true,
appBar: AppBar(
elevation: 0,
leading: IconButton(
2021-10-14 18:09:30 +02:00
icon: const Icon(Icons.close),
2021-05-25 20:41:37 +02:00
onPressed: Navigator.of(context).pop,
color: Colors.white,
2022-01-29 12:35:03 +01:00
tooltip: L10n.of(context)!.close,
2021-05-25 20:41:37 +02:00
),
2021-10-14 18:09:30 +02:00
backgroundColor: const Color(0x44000000),
2021-05-25 20:41:37 +02:00
actions: [
IconButton(
2021-10-14 18:09:30 +02:00
icon: const Icon(Icons.reply_outlined),
2021-05-25 20:41:37 +02:00
onPressed: controller.forwardAction,
color: Colors.white,
2022-01-29 12:35:03 +01:00
tooltip: L10n.of(context)!.share,
2021-05-25 20:41:37 +02:00
),
2022-05-06 08:27:38 +02:00
if (!PlatformInfos.isIOS)
IconButton(
2022-05-05 09:13:54 +02:00
icon: const Icon(Icons.download_outlined),
2022-08-21 08:42:02 +02:00
onPressed: () => controller.saveFileAction(context),
color: Colors.white,
2022-05-05 09:13:54 +02:00
tooltip: L10n.of(context)!.downloadFile,
),
2022-05-06 08:27:38 +02:00
if (PlatformInfos.isMobile)
2022-08-21 08:42:02 +02:00
// Use builder context to correctly position the share dialog on iPad
Builder(
builder: (context) => IconButton(
onPressed: () => controller.shareFileAction(context),
tooltip: L10n.of(context)!.share,
color: Colors.white,
icon: Icon(Icons.adaptive.share_outlined),
))
2021-05-25 20:41:37 +02:00
],
),
body: InteractiveViewer(
minScale: 1.0,
maxScale: 10.0,
onInteractionEnd: controller.onInteractionEnds,
child: Center(
child: Hero(
tag: controller.widget.event.eventId,
child: MxcImage(
event: controller.widget.event,
fit: BoxFit.contain,
isThumbnail: false,
animated: true,
),
2021-05-25 20:41:37 +02:00
),
),
),
);
2020-05-16 08:02:33 +02:00
}
}