fluffychat/lib/pages/views/image_viewer_view.dart

84 lines
2.8 KiB
Dart
Raw Normal View History

2021-05-25 15:35:14 +02:00
import 'package:famedlysdk/famedlysdk.dart';
import '../image_viewer.dart';
import 'package:fluffychat/widgets/event_content/image_bubble.dart';
2020-05-16 08:02:33 +02:00
import 'package:flutter/material.dart';
2021-02-20 07:40:42 +01:00
import 'package:flutter_gen/gen_l10n/l10n.dart';
2020-05-16 08:02:33 +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
2021-05-22 09:13:47 +02: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 15:35:14 +02:00
return FutureBuilder<Event>(
future: controller.getEvent(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
elevation: 0,
backgroundColor: Color(0x44000000),
),
body: Center(
child: snapshot.hasError
? Text(
L10n.of(context).oopsSomethingWentWrong,
style: TextStyle(color: Colors.white),
textAlign: TextAlign.center,
)
: CircularProgressIndicator()),
);
}
final event = snapshot.data;
return Scaffold(
backgroundColor: Colors.black,
2021-05-25 15:35:14 +02:00
extendBodyBehindAppBar: true,
appBar: AppBar(
elevation: 0,
backgroundColor: Color(0x44000000),
leading: IconButton(
icon: Icon(Icons.close),
onPressed: Navigator.of(context, rootNavigator: false).pop,
color: Colors.white,
tooltip: L10n.of(context).close,
),
actions: [
IconButton(
icon: Icon(Icons.reply_outlined),
onPressed: () => controller.forwardAction(event),
color: Colors.white,
tooltip: L10n.of(context).share,
),
IconButton(
icon: Icon(Icons.download_outlined),
onPressed: () => controller.openFileAction(event),
color: Colors.white,
tooltip: L10n.of(context).downloadFile,
),
],
),
body: InteractiveViewer(
minScale: 1.0,
maxScale: 10.0,
onInteractionEnd: controller.onInteractionEnds,
child: Center(
child: ImageBubble(
event,
tapToView: false,
onLoaded: controller.widget.onLoaded,
fit: BoxFit.contain,
backgroundColor: Colors.black,
maxSize: false,
radius: 0.0,
thumbnailOnly: false,
),
),
),
);
});
2020-05-16 08:02:33 +02:00
}
}