remove `Dismissible` and instead use `GestureDetector` for dismissal

This commit is contained in:
krawieck 2020-09-15 16:03:52 +02:00
parent abb107fbbf
commit 024a2ce981
1 changed files with 20 additions and 24 deletions

View File

@ -87,30 +87,26 @@ class MediaViewPage extends HookWidget {
], ],
) )
: null, : null,
body: Dismissible( body: GestureDetector(
direction: DismissDirection.vertical, onTapUp: (details) => showButtons.value = !showButtons.value,
onDismissed: (_) => Navigator.of(context).pop(), onVerticalDragEnd: isZoomedOut.value
key: const Key('media view'), ? (details) {
background: Container(color: Colors.black), if (details.primaryVelocity.abs() > 1000) {
dismissThresholds: { Navigator.of(context).pop();
DismissDirection.vertical: 0, }
}, }
confirmDismiss: (direction) => Future.value(isZoomedOut.value), : null,
resizeDuration: null, child: PhotoView(
child: GestureDetector( scaleStateChangedCallback: (value) {
onTapUp: (details) => showButtons.value = !showButtons.value, isZoomedOut.value = value == PhotoViewScaleState.zoomedOut ||
child: PhotoView( value == PhotoViewScaleState.initial;
scaleStateChangedCallback: (value) { },
isZoomedOut.value = value == PhotoViewScaleState.zoomedOut || minScale: PhotoViewComputedScale.contained,
value == PhotoViewScaleState.initial; initialScale: PhotoViewComputedScale.contained,
}, imageProvider: CachedNetworkImageProvider(url),
minScale: PhotoViewComputedScale.contained, heroAttributes: PhotoViewHeroAttributes(tag: url),
initialScale: PhotoViewComputedScale.contained, loadingBuilder: (context, event) =>
imageProvider: CachedNetworkImageProvider(url), Center(child: CircularProgressIndicator()),
heroAttributes: PhotoViewHeroAttributes(tag: url),
loadingBuilder: (context, event) =>
Center(child: CircularProgressIndicator()),
),
), ),
), ),
); );