Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add option to allow swipe-down to dismiss #21

Merged
merged 3 commits into from
Aug 4, 2022

Conversation

jfahrenkrug
Copy link
Collaborator

Description

A ticket asked for swipe-to-dismiss (#14)
It's easy to implement and now supported with the swipeDismissible argument.
This allows the user to drag the dialog down to dismiss it.

Initially there was a problem when the user zoomed in and tried to pan around on the
zoomed-in image: The Dismissible widget's GestureDetector would take over and
enter the dismissal animation. Watching the image's scale and then changing the Dismissible's
dismissDirection from down to none solves the issue. However, additionally a
GlobalObjectKey was needed for the PageView because Dismissible changes the location of
the widget in the widget tree when its dismissDirection is changed to none.

See https://github.com/flutter/flutter/blob/2aa348b9407e96ffe4eca8e8f213c7984afad3f7/packages/flutter/lib/src/widgets/dismissible.dart#L692
See flutter/flutter#108961
See https://www.youtube.com/watch?v=kn0EOS-ZiIc

  • The commit messages follow our guidelines (CONTRIBUTING.md)
  • Tests for any changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Type

What kind of change does this pull request introduce?

[ ] Bug fix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other (please describe below)

Breaking Changes

Does this pull request introduce any breaking changes?

[ ] Yes
[X] No

A ticket asked for swipe-to-dismiss (#14)
It's easy to implement and now supported with the `swipeDismissible` argument.
This allows the user to drag the dialog down to dismiss it.

Initially there was a problem when the user zoomed in and tried to pan around on the
zoomed-in image: The `Dismissible` widget's GestureDetector would take over and
enter the dismissal animation. Watching the image's scale and then changing the Dismissible's
`dismissDirection` from `down` to `none` solves the issue. However, additionally a
`GlobalObjectKey` was needed for the PageView because Dismissible changes the location of
the widget in the widget tree when its `dismissDirection` is changed to `none`.

See https://github.com/flutter/flutter/blob/2aa348b9407e96ffe4eca8e8f213c7984afad3f7/packages/flutter/lib/src/widgets/dismissible.dart#L692
See flutter/flutter#108961
See https://www.youtube.com/watch?v=kn0EOS-ZiIc
@jfahrenkrug jfahrenkrug merged commit 9c1b1ef into main Aug 4, 2022
@jfahrenkrug jfahrenkrug deleted the add_swipe_to_dismiss branch August 4, 2022 15:39
@felipebueno
Copy link

Hey, @jfahrenkrug! Thanks for this useful plugin! 🙂

Are you planning to publish v1.0.5 on pub.dev soon? I want to implement swipe to dismiss on my app.

@jfahrenkrug
Copy link
Collaborator Author

@felipebueno Hey Felipe, thank you :) We've just released version 1.1.0: https://pub.dev/packages/easy_image_viewer/changelog#110 Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants