fix: improve image viewer gestures (driver approach)#2434
Conversation
Replaces gesture arena logic with a driver approach where InteractiveViewer handles all touches. Adds manual scroll driving, double-tap zoom, and reliable pinch-to-zoom transition.
| @@ -0,0 +1,108 @@ | |||
| import 'package:flutter/material.dart'; | |||
|
|
|||
| class ZoomableImage extends StatefulWidget { | |||
There was a problem hiding this comment.
Where do you have this code from? Is it from a package or an example from stackoverflow?
| // We disable the intrinsic scrolling of the PageView because we want | ||
| // the [ZoomableImage] to drive the scrolling manually. | ||
| // This allows us to seamlessly switch between scrolling (1 finger) | ||
| // and zooming (2 fingers) without the Gesture Arena locking us out. |
There was a problem hiding this comment.
This all looks like a lot of workarounds for something that should be built into the framework. Are you sure this is the correct approach, that we maintain 174 new lines of code by ourself?
There was a problem hiding this comment.
I had a dig around and found the main issue is that the viewer is in a scroll widget. As soon as the scroll moves a tiny amount, it takes control of the gestures.
I tried working around the issue, but couldn't get it to work. So this was a better solution. It's still not great and the image viewer experience is still frustrating.
Maybe it would be better to use a specific library designed for image gallery. This would reduce the burden of image viewer maintenance and usability. The following looks to be popular and easy to use.
|
Thank you so much for working on this. Zooming not working as expected is a really annoying bug … But when we're at it, I would like to add another aspect: In virtually all apps, browsing through images is implemented as swiping left and right. Here, we swipe up and down to do that. Whilst one could argue that this is what we do to navigate through the chat history, it's not what one would expect. Maybe it would be worth considering changing this, too? Thanks again! |
Replaces gesture arena logic with a driver approach where InteractiveViewer handles all touches. Adds manual scroll driving, double-tap zoom, and reliable pinch-to-zoom transition.
Thank you so much for your contribution to FluffyChat ❤️❤️❤️
Pull Request has been tested on: