fluffychat/lib/views/image_view.dart

62 lines
1.7 KiB
Dart
Raw Normal View History

2020-05-16 08:02:33 +02:00
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/image_bubble.dart';
import 'package:fluffychat/components/matrix.dart';
import 'package:flutter/material.dart';
2020-09-07 17:08:01 +02:00
import 'package:photo_view/photo_view.dart';
2020-05-16 08:02:33 +02:00
import '../utils/event_extension.dart';
class ImageView extends StatelessWidget {
final Event event;
final void Function() onLoaded;
2020-05-16 08:02:33 +02:00
const ImageView(this.event, {Key key, this.onLoaded}) : super(key: key);
2020-05-16 08:02:33 +02:00
void _forwardAction(BuildContext context) async {
Matrix.of(context).shareContent = event.content;
Navigator.of(context).popUntil((r) => r.isFirst);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
2020-05-20 19:29:26 +02:00
extendBodyBehindAppBar: true,
2020-05-16 08:02:33 +02:00
appBar: AppBar(
2020-05-20 19:29:26 +02:00
elevation: 0,
2020-05-16 08:02:33 +02:00
leading: IconButton(
icon: Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
color: Colors.white,
),
2020-05-20 19:29:26 +02:00
backgroundColor: Color(0x44000000),
2020-05-16 08:02:33 +02:00
actions: [
IconButton(
2020-12-06 10:31:35 +01:00
icon: Icon(Icons.reply_outlined),
2020-05-16 08:02:33 +02:00
onPressed: () => _forwardAction(context),
color: Colors.white,
),
IconButton(
2020-12-06 10:31:35 +01:00
icon: Icon(Icons.download_outlined),
2020-09-03 12:58:54 +02:00
onPressed: () => event.openFile(context, downloadOnly: true),
2020-05-16 08:02:33 +02:00
color: Colors.white,
),
],
),
2020-09-07 17:08:01 +02:00
body: PhotoView.customChild(
2020-05-16 09:12:57 +02:00
minScale: 1.0,
2020-05-16 09:13:37 +02:00
maxScale: 10.0,
2020-05-20 19:29:26 +02:00
child: ImageBubble(
event,
tapToView: false,
onLoaded: onLoaded,
2020-05-20 19:29:26 +02:00
fit: BoxFit.contain,
backgroundColor: Colors.black,
maxSize: false,
radius: 0.0,
2020-09-03 12:58:54 +02:00
thumbnailOnly: false,
2020-05-20 19:29:26 +02:00
),
2020-05-16 08:02:33 +02:00
),
);
}
}