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
Add backGestureDetectionStart parameter #14
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ class SwipeablePageRoute<T> extends CupertinoPageRoute<T> { | |
this.canSwipe = true, | ||
this.canOnlySwipeFromEdge = false, | ||
this.backGestureDetectionWidth = kMinInteractiveDimension, | ||
this.backGestureDetectionStart = 0.0, | ||
required WidgetBuilder builder, | ||
String? title, | ||
RouteSettings? settings, | ||
|
@@ -43,12 +44,14 @@ class SwipeablePageRoute<T> extends CupertinoPageRoute<T> { | |
/// 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about renaming this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. backGestureDetectionStart looks fine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I mean backGestureDetectionStartOffset |
||
|
||
@override | ||
bool get popGestureEnabled => canSwipe && super.popGestureEnabled; | ||
|
@@ -95,6 +98,7 @@ class SwipeablePageRoute<T> extends CupertinoPageRoute<T> { | |
onStartPopGesture: _startPopGesture, | ||
canOnlySwipeFromEdge: canOnlySwipeFromEdge, | ||
backGestureDetectionWidth: backGestureDetectionWidth, | ||
backGestureDetectionStart: backGestureDetectionStart, | ||
child: child, | ||
), | ||
); | ||
|
@@ -128,13 +132,15 @@ class _FancyBackGestureDetector<T> extends StatefulWidget { | |
Key? key, | ||
required this.canOnlySwipeFromEdge, | ||
required this.backGestureDetectionWidth, | ||
required this.backGestureDetectionStart, | ||
required this.enabledCallback, | ||
required this.onStartPopGesture, | ||
required this.child, | ||
}) : super(key: key); | ||
|
||
final bool canOnlySwipeFromEdge; | ||
final double backGestureDetectionWidth; | ||
final double backGestureDetectionStart; | ||
|
||
final Widget child; | ||
final ValueGetter<bool> enabledCallback; | ||
|
@@ -217,6 +223,7 @@ class _FancyBackGestureDetectorState<T> | |
: MediaQuery.of(context).padding.right; | ||
dragAreaWidth = max(dragAreaWidth, widget.backGestureDetectionWidth); | ||
|
||
|
||
final listener = Listener( | ||
onPointerDown: (event) { | ||
if (widget.enabledCallback()) _recognizer.addPointer(event); | ||
|
@@ -229,7 +236,7 @@ class _FancyBackGestureDetectorState<T> | |
widget.child, | ||
if (widget.canOnlySwipeFromEdge) | ||
PositionedDirectional( | ||
start: 0, | ||
start: widget.backGestureDetectionStart, | ||
width: dragAreaWidth, | ||
top: 0, | ||
bottom: 0, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.