PiN73 / cupertino_back_gesture

Flutter package to set custom width of iOS back swipe gesture area
BSD 3-Clause "New" or "Revised" License
30 stars 17 forks source link

It is conflict with TabBar&TabBarView #10

Open houleixx opened 3 years ago

houleixx commented 3 years ago

It is conflict with TabBar&TabBarView。 It is conflict with ListView( scrollDirection : Axis.horizontal)。

emvaized commented 3 years ago

I guess you should implement your own GestureArena, like described in this article: https://medium.com/koahealth/combining-multiple-gesturedetectors-in-flutter-26d899d008b2

SteveJob commented 3 years ago

It is conflict with TabBar&TabBarView。 It is conflict with ListView( scrollDirection : Axis.horizontal)。

Has the problem been solved now?

ivanbogomoloff commented 5 months ago

Workaround is RawGestureDetector with hardcoded swipe zone.

child: RawGestureDetector(
                        gestures: {
                          AllowMultipleGestureRecognizer:
                          GestureRecognizerFactoryWithHandlers<
                              AllowMultipleGestureRecognizer>(
                                () => AllowMultipleGestureRecognizer(),  //constructor
                                (AllowMultipleGestureRecognizer instance) {

                              instance.onCancel = () {
                                setState(() {
                                  _tabPhysics = const ScrollPhysics();
                                });
                              };
                              instance.onDown = (position) {
                                setState(() {
                                  /// 199 - it's magic left side zone on screen. I think it can be about 200-250 in my case it's ok.
                                  if(_tabController!.index == 0 && position.localPosition.dx <= 199) {
                                      _tabPhysics = const NeverScrollableScrollPhysics();
                                  } else {
                                    _tabPhysics = const ScrollPhysics();
                                  }
                                });
                              };
                            },
                          )
                        },
                      child: TabBarView(
                        physics: _tabPhysics,
                        controller: _tabController,
                        children: tabs.map((tab) => AdvertListWidget(items: tab.items)).toList(),
                      ),
                    )
//
class AllowMultipleGestureRecognizer extends VerticalDragGestureRecognizer
{
  @override
  void rejectGesture(int pointer) {

    acceptGesture(pointer);
  }
}

And in _tabController i change physics

_tabController!.addListener(() {
   setState(() {
      _tabPhysics = const ScrollPhysics();
    });
});