diff --git a/lib/src/page_route.dart b/lib/src/page_route.dart index c45609b..24ce7a8 100644 --- a/lib/src/page_route.dart +++ b/lib/src/page_route.dart @@ -15,6 +15,7 @@ class SwipeablePageRoute extends CupertinoPageRoute { this.canSwipe = true, this.canOnlySwipeFromEdge = false, this.backGestureDetectionWidth = kMinInteractiveDimension, + this.backGestureDetectionStart = 0.0, required WidgetBuilder builder, String? title, RouteSettings? settings, @@ -51,12 +52,14 @@ class SwipeablePageRoute extends CupertinoPageRoute { /// If set to `false`, the user can start dragging anywhere on the screen. final bool canOnlySwipeFromEdge; + /// If [canOnlySwipeFromEdge] is set to `true`, this value controls + /// width of gesture detection area + final double backGestureDetectionWidth; + /// If [canOnlySwipeFromEdge] is set to `true`, this value controls how far /// away from the left (LTR) or right (RTL) screen edge a gesture must start /// to be recognized for back navigation. - /// - /// In [CupertinoPageRoute], this value is `20`. - final double backGestureDetectionWidth; + final double backGestureDetectionStart; @override bool get popGestureEnabled => canSwipe && super.popGestureEnabled; @@ -103,6 +106,7 @@ class SwipeablePageRoute extends CupertinoPageRoute { onStartPopGesture: _startPopGesture, canOnlySwipeFromEdge: canOnlySwipeFromEdge, backGestureDetectionWidth: backGestureDetectionWidth, + backGestureDetectionStart: backGestureDetectionStart, child: child, ), ); @@ -136,6 +140,7 @@ class _FancyBackGestureDetector extends StatefulWidget { Key? key, required this.canOnlySwipeFromEdge, required this.backGestureDetectionWidth, + required this.backGestureDetectionStart, required this.enabledCallback, required this.onStartPopGesture, required this.child, @@ -143,6 +148,7 @@ class _FancyBackGestureDetector extends StatefulWidget { final bool canOnlySwipeFromEdge; final double backGestureDetectionWidth; + final double backGestureDetectionStart; final Widget child; final ValueGetter enabledCallback; @@ -225,6 +231,7 @@ class _FancyBackGestureDetectorState : MediaQuery.of(context).padding.right; dragAreaWidth = max(dragAreaWidth, widget.backGestureDetectionWidth); + final listener = Listener( onPointerDown: (event) { if (widget.enabledCallback()) _recognizer.addPointer(event); @@ -237,7 +244,7 @@ class _FancyBackGestureDetectorState widget.child, if (widget.canOnlySwipeFromEdge) PositionedDirectional( - start: 0, + start: widget.backGestureDetectionStart, width: dragAreaWidth, top: 0, bottom: 0,