FurryChat/lib/views/image_viewer.dart

46 lines
1.2 KiB
Dart
Raw Normal View History

2020-02-16 11:35:04 +00:00
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
import 'package:url_launcher/url_launcher.dart';
class ImageViewer extends StatelessWidget {
final MxContent mxContent;
const ImageViewer(this.mxContent);
static show(BuildContext context, MxContent content) {
2020-02-23 07:49:58 +00:00
Navigator.of(context).push(
AppRoute(
ImageViewer(content),
),
);
2020-02-16 11:35:04 +00:00
}
@override
Widget build(BuildContext context) {
final String url = mxContent.getDownloadLink(Matrix.of(context).client);
return Scaffold(
2020-02-23 10:02:59 +00:00
backgroundColor: Colors.black,
2020-02-16 11:35:04 +00:00
appBar: AppBar(
2020-02-23 07:49:58 +00:00
brightness: Brightness.dark,
backgroundColor: Colors.black,
iconTheme: IconThemeData(color: Colors.white),
2020-02-16 11:35:04 +00:00
actions: <Widget>[
IconButton(
icon: Icon(Icons.file_download),
onPressed: () => launch(url),
),
],
),
body: PhotoView(
loadingBuilder: (c, i) => Center(child: CircularProgressIndicator()),
2020-02-23 10:20:25 +00:00
imageProvider: NetworkImage(
2020-02-16 11:35:04 +00:00
url,
),
),
);
}
}