Skip to content

Commit

Permalink
fix: disable dismiss gesture if zoomed (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon authored Jun 26, 2024
1 parent d9caa9e commit 0ce0301
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/view/dialog/image_gallery_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ class ImageGalleryDialog extends HookConsumerWidget {
[],
);
final comment = files[index.value].comment;
final isZoomed = useState(false);

return Stack(
children: [
Dismissible(
key: const ValueKey(0),
direction: DismissDirection.vertical,
direction: !isZoomed.value
? DismissDirection.vertical
: DismissDirection.none,
onDismissed: (_) => context.pop(),
child: FocusableActionDetector(
autofocus: true,
Expand Down Expand Up @@ -75,6 +78,15 @@ class ImageGalleryDialog extends HookConsumerWidget {
itemCount: files.length,
backgroundDecoration:
const BoxDecoration(color: Colors.transparent),
scaleStateChangedCallback: (state) => switch (state) {
PhotoViewScaleState.initial ||
PhotoViewScaleState.zoomedOut =>
isZoomed.value = false,
PhotoViewScaleState.covering ||
PhotoViewScaleState.originalSize ||
PhotoViewScaleState.zoomedIn =>
isZoomed.value = true,
},
),
),
),
Expand Down Expand Up @@ -168,8 +180,8 @@ class ImageGalleryDialog extends HookConsumerWidget {
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
height: 100.0,
child: ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 100.0),
child: SingleChildScrollView(
child: Text(
comment != null && comment.isNotEmpty
Expand Down

0 comments on commit 0ce0301

Please sign in to comment.