fluffychat/lib/pages/image_viewer/image_viewer_view.dart

70 lines
2.1 KiB
Dart
Raw Normal View History

2020-05-16 06:02:33 +00:00
import 'package:flutter/material.dart';
2021-10-26 16:50:34 +00:00
2021-02-20 06:40:42 +00:00
import 'package:flutter_gen/gen_l10n/l10n.dart';
2020-05-16 06:02:33 +00:00
2021-11-09 20:32:16 +00:00
import 'package:fluffychat/pages/chat/events/image_bubble.dart';
import 'package:fluffychat/utils/platform_infos.dart';
2021-11-09 20:32:16 +00:00
import 'image_viewer.dart';
2021-10-26 16:50:34 +00:00
2021-05-22 07:13:47 +00:00
class ImageViewerView extends StatelessWidget {
2021-04-10 07:06:24 +00:00
final ImageViewerController controller;
2020-05-16 06:02:33 +00:00
2022-01-29 11:35:03 +00:00
const ImageViewerView(this.controller, {Key? key}) : super(key: key);
2020-05-16 06:02:33 +00:00
@override
Widget build(BuildContext context) {
2021-05-25 18:41:37 +00:00
return Scaffold(
backgroundColor: Colors.black,
extendBodyBehindAppBar: true,
appBar: AppBar(
elevation: 0,
leading: IconButton(
2021-10-14 16:09:30 +00:00
icon: const Icon(Icons.close),
2021-05-25 18:41:37 +00:00
onPressed: Navigator.of(context).pop,
color: Colors.white,
2022-01-29 11:35:03 +00:00
tooltip: L10n.of(context)!.close,
2021-05-25 18:41:37 +00:00
),
2021-10-14 16:09:30 +00:00
backgroundColor: const Color(0x44000000),
2021-05-25 18:41:37 +00:00
actions: [
IconButton(
2021-10-14 16:09:30 +00:00
icon: const Icon(Icons.reply_outlined),
2021-05-25 18:41:37 +00:00
onPressed: controller.forwardAction,
color: Colors.white,
2022-01-29 11:35:03 +00:00
tooltip: L10n.of(context)!.share,
2021-05-25 18:41:37 +00:00
),
IconButton(
2021-10-14 16:09:30 +00:00
icon: const Icon(Icons.download_outlined),
2021-07-11 15:12:56 +00:00
onPressed: controller.saveFileAction,
2021-05-25 18:41:37 +00:00
color: Colors.white,
2022-01-29 11:35:03 +00:00
tooltip: L10n.of(context)!.downloadFile,
2021-05-25 18:41:37 +00:00
),
if (PlatformInfos.isAndroid)
IconButton(
onPressed: controller.shareFileAction,
tooltip: L10n.of(context)!.share,
color: Colors.white,
icon: const Icon(Icons.share),
)
2021-05-25 18:41:37 +00:00
],
),
body: InteractiveViewer(
minScale: 1.0,
maxScale: 10.0,
onInteractionEnd: controller.onInteractionEnds,
child: Center(
child: ImageBubble(
controller.widget.event,
tapToView: false,
onLoaded: controller.widget.onLoaded,
fit: BoxFit.contain,
backgroundColor: Colors.black,
2021-05-25 18:41:37 +00:00
maxSize: false,
thumbnailOnly: false,
animated: true,
2021-05-25 18:41:37 +00:00
),
),
),
);
2020-05-16 06:02:33 +00:00
}
}