Ignore swipes initiated from inside system gesture
This commit is contained in:
parent
976427f9df
commit
3ae1548ba0
|
@ -204,6 +204,9 @@ class _SwipeableState extends State<Swipeable> with TickerProviderStateMixin, Au
|
||||||
|
|
||||||
bool _isTouch = true;
|
bool _isTouch = true;
|
||||||
|
|
||||||
|
double? _minX;
|
||||||
|
double? _maxX;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => _moveController.isAnimating == true;
|
bool get wantKeepAlive => _moveController.isAnimating == true;
|
||||||
|
|
||||||
|
@ -237,8 +240,20 @@ class _SwipeableState extends State<Swipeable> with TickerProviderStateMixin, Au
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handlePointerDown(PointerDownEvent event) {
|
void _handlePointerDown(PointerDownEvent event) {
|
||||||
|
final xPos = event.position.dx;
|
||||||
|
|
||||||
|
var validTouch = widget.allowedPointerKinds.contains(event.kind);
|
||||||
|
|
||||||
|
if(validTouch && _minX != null){
|
||||||
|
validTouch = xPos > _minX!;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(validTouch && _maxX != null){
|
||||||
|
validTouch = xPos < _maxX!;
|
||||||
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isTouch = widget.allowedPointerKinds.contains(event.kind);
|
_isTouch = validTouch;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,6 +444,18 @@ class _SwipeableState extends State<Swipeable> with TickerProviderStateMixin, Au
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaQueryData? mediaQuery = MediaQuery.maybeOf(context);
|
||||||
|
if (mediaQuery != null) {
|
||||||
|
if(_minX == null || _maxX == null){
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
setState(() {
|
||||||
|
_minX = mediaQuery.systemGestureInsets.left;
|
||||||
|
_maxX = mediaQuery.size.width - mediaQuery.systemGestureInsets.right;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget content = SlideTransition(
|
Widget content = SlideTransition(
|
||||||
position: _moveAnimation,
|
position: _moveAnimation,
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
|
|
Loading…
Reference in a new issue