Photo_view: Can gallery mode support 'detect image edge' but not unlock when contained?

Created on 20 Oct 2018  Â·  8Comments  Â·  Source: fireslime/photo_view

I find out that the gallery mode is something like twitter-mode: you can't change image if its scale is bigger than 1.0 or _locked = scaleState != PhotoViewScaleState.contained.

So, is there any way to make _locked = false, while swipe reaches the image's edge(left or right), no matter whats scale the image has. And also swipe up or swipe down to close when reaches the image's edge(top or bottom).

What I'm saying is something like this(WeChat app):

ezgif com-resize

But not use the _lock when contained happens:

// this is from the source
  void scaleStateChangedCallback(PhotoViewScaleState scaleState) {
    setState(() {
      _locked = scaleState != PhotoViewScaleState.contained;
    });
  }

// may be
  void scaleStateChangedCallback(PhotoViewScaleState scaleState) {
    setState(() {
      _locked = notReachTheImageEdge();
    });
  }
Gallery enhancement help wanted physics

Most helpful comment

Great idea @dasmikko I will work on something like that soon (more callbacks).

All 8 comments

That will be tricky due to PageView's behavior. Let's see what we can do about that.

A possible solution:

Have a callback methods that fires each time the image panned and then returns ithe current state like so:

  • AtInitialSize
  • AtScreenEdge
  • Panning (Needs a better name, but it's neither at initialSize nor edge)

Then you simple can set the PageView's physics based on that,

Correct me if i'm wrong.

Great idea @dasmikko I will work on something like that soon (more callbacks).

When I implemented this scheme, I added a callback method to check the touch margin. When I touched the margin, I made locked=false, and at the same time judged the initial direction of the sliding gesture. Locked=true when sliding in the opposite direction. But the process of implementation I have encountered a problem, when my scrollListener listens to the reverse slide, making locked=true will make the page card master, and there is no error message. @Shu-Ji @dasmikko @renancaraujo

Can you add a WeChat friend to solve this problem? @Shu-Ji My wechat Id NA0421

@LebenNNA I've tried that before, but failed. It's tricky like @renancaraujo said. Detecting gestures is a bit difficult in Flutter.
Maybe we should wait some genius to solve this problem...

The basic effect I made but encountered a problem with the PageView's framwork, I have already submitted the issue @Shu-Ji @renancaraujo

Released a tackle for this on 0.7.0. Thanks to @criswonder

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Purus picture Purus  Â·  3Comments

bombert picture bombert  Â·  9Comments

criswonder picture criswonder  Â·  5Comments

renancaraujo picture renancaraujo  Â·  3Comments

flikkr picture flikkr  Â·  5Comments