mirror of
https://github.com/krille-chan/fluffychat
synced 2024-10-10 09:03:38 +00:00
88 lines
2.8 KiB
Dart
88 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
|
import 'package:fluffychat/widgets/mxc_image.dart';
|
|
import 'image_viewer.dart';
|
|
|
|
class ImageViewerView extends StatelessWidget {
|
|
final ImageViewerController controller;
|
|
|
|
const ImageViewerView(this.controller, {super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.black.withOpacity(0.5),
|
|
extendBodyBehindAppBar: true,
|
|
appBar: AppBar(
|
|
elevation: 0,
|
|
leading: IconButton(
|
|
style: IconButton.styleFrom(
|
|
backgroundColor: Colors.black.withOpacity(0.5),
|
|
),
|
|
icon: const Icon(Icons.close),
|
|
onPressed: Navigator.of(context).pop,
|
|
color: Colors.white,
|
|
tooltip: L10n.of(context)!.close,
|
|
),
|
|
backgroundColor: Colors.transparent,
|
|
actions: [
|
|
IconButton(
|
|
style: IconButton.styleFrom(
|
|
backgroundColor: Colors.black.withOpacity(0.5),
|
|
),
|
|
icon: const Icon(Icons.reply_outlined),
|
|
onPressed: controller.forwardAction,
|
|
color: Colors.white,
|
|
tooltip: L10n.of(context)!.share,
|
|
),
|
|
const SizedBox(width: 8),
|
|
IconButton(
|
|
style: IconButton.styleFrom(
|
|
backgroundColor: Colors.black.withOpacity(0.5),
|
|
),
|
|
icon: const Icon(Icons.download_outlined),
|
|
onPressed: () => controller.saveFileAction(context),
|
|
color: Colors.white,
|
|
tooltip: L10n.of(context)!.downloadFile,
|
|
),
|
|
const SizedBox(width: 8),
|
|
if (PlatformInfos.isMobile)
|
|
// Use builder context to correctly position the share dialog on iPad
|
|
Padding(
|
|
padding: const EdgeInsets.only(right: 8.0),
|
|
child: Builder(
|
|
builder: (context) => IconButton(
|
|
style: IconButton.styleFrom(
|
|
backgroundColor: Colors.black.withOpacity(0.5),
|
|
),
|
|
onPressed: () => controller.shareFileAction(context),
|
|
tooltip: L10n.of(context)!.share,
|
|
color: Colors.white,
|
|
icon: Icon(Icons.adaptive.share_outlined),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
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,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|