2021-01-16 12:46:38 +01:00
|
|
|
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
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';
|
|
|
|
import '../utils/event_extension.dart';
|
2021-02-20 07:40:42 +01:00
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
2021-01-18 07:56:02 +01:00
|
|
|
import '../utils/platform_infos.dart';
|
2020-05-16 08:02:33 +02:00
|
|
|
|
|
|
|
class ImageView extends StatelessWidget {
|
|
|
|
final Event event;
|
2020-11-17 12:59:34 +01:00
|
|
|
final void Function() onLoaded;
|
2020-05-16 08:02:33 +02:00
|
|
|
|
2020-11-17 12:59:34 +01: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;
|
2021-01-16 12:46:38 +01:00
|
|
|
AdaptivePageLayout.of(context).popUntilIsFirst();
|
2020-05-16 08:02:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-01-18 07:56:02 +01:00
|
|
|
var calcVelocity = MediaQuery.of(context).size.height * 1.50;
|
|
|
|
|
2020-05-16 08:02:33 +02:00
|
|
|
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),
|
2021-02-24 12:17:23 +01:00
|
|
|
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
|
2020-05-16 08:02:33 +02:00
|
|
|
color: Colors.white,
|
2021-02-20 07:40:42 +01:00
|
|
|
tooltip: L10n.of(context).close,
|
2020-05-16 08:02:33 +02:00
|
|
|
),
|
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,
|
2021-02-20 07:40:42 +01:00
|
|
|
tooltip: L10n.of(context).share,
|
2020-05-16 08:02:33 +02:00
|
|
|
),
|
|
|
|
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,
|
2021-02-20 07:40:42 +01:00
|
|
|
tooltip: L10n.of(context).downloadFile,
|
2020-05-16 08:02:33 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2021-01-18 07:56:02 +01:00
|
|
|
body: InteractiveViewer(
|
2021-03-04 12:28:06 +01:00
|
|
|
minScale: 1.0,
|
|
|
|
maxScale: 10.0,
|
|
|
|
onInteractionEnd: (ScaleEndDetails endDetails) {
|
|
|
|
if (PlatformInfos.usesTouchscreen == false) {
|
|
|
|
if (endDetails.velocity.pixelsPerSecond.dy > calcVelocity) {
|
|
|
|
Navigator.of(context, rootNavigator: false).pop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-01-18 07:56:02 +01:00
|
|
|
child: Center(
|
|
|
|
child: ImageBubble(
|
|
|
|
event,
|
|
|
|
tapToView: false,
|
|
|
|
onLoaded: onLoaded,
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
backgroundColor: Colors.black,
|
|
|
|
maxSize: false,
|
|
|
|
radius: 0.0,
|
|
|
|
thumbnailOnly: false,
|
|
|
|
),
|
|
|
|
),
|
2020-05-16 08:02:33 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|