Add media view widget
This commit is contained in:
parent
c5e90346fe
commit
5fa9e22cd5
|
@ -0,0 +1,50 @@
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
|
||||
class MediaView extends HookWidget {
|
||||
final String url;
|
||||
|
||||
const MediaView(this.url);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var showButtons = useState(true);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor:
|
||||
showButtons.value ? Colors.black38 : Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
leading: showButtons.value ? CloseButton() : Container(),
|
||||
actions: showButtons.value
|
||||
? [
|
||||
IconButton(
|
||||
icon: Icon(Icons.share),
|
||||
tooltip: 'share',
|
||||
onPressed: () {},
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.file_download),
|
||||
tooltip: 'download',
|
||||
onPressed: () {},
|
||||
),
|
||||
]
|
||||
: null,
|
||||
),
|
||||
extendBodyBehindAppBar: true,
|
||||
body: GestureDetector(
|
||||
onTapUp: (details) => showButtons.value = !showButtons.value,
|
||||
child: PhotoView(
|
||||
minScale: PhotoViewComputedScale.contained,
|
||||
initialScale: PhotoViewComputedScale.contained,
|
||||
imageProvider: CachedNetworkImageProvider(url),
|
||||
heroAttributes: PhotoViewHeroAttributes(tag: url),
|
||||
loadingBuilder: (context, event) =>
|
||||
Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -471,6 +471,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
photo_view:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: photo_view
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.10.2"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -21,6 +21,7 @@ environment:
|
|||
sdk: '>=2.7.0 <3.0.0'
|
||||
|
||||
dependencies:
|
||||
photo_view: ^0.10.2
|
||||
url_launcher: ^5.5.1
|
||||
markdown: ^2.1.8
|
||||
flutter_markdown: ^0.4.3
|
||||
|
@ -51,7 +52,6 @@ dev_dependencies:
|
|||
mobx_codegen: ^1.1.0
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter.
|
||||
flutter:
|
||||
# The following line ensures that the Material Icons font is
|
||||
|
|
Loading…
Reference in New Issue