Commit 5ee8390e authored by xster's avatar xster Committed by GitHub

Let iOS back gesture listen to edge swipes only (#11559)

* Make iOS back gesture triggerable from the edge only.

* change to positioned
parent 2877dda5
...@@ -450,10 +450,15 @@ class _CupertinoBackGestureDetectorState extends State<_CupertinoBackGestureDete ...@@ -450,10 +450,15 @@ class _CupertinoBackGestureDetectorState extends State<_CupertinoBackGestureDete
fit: StackFit.passthrough, fit: StackFit.passthrough,
children: <Widget>[ children: <Widget>[
widget.child, widget.child,
new Listener( new Positioned(
onPointerDown: _handlePointerDown, left: 0.0,
behavior: HitTestBehavior.translucent, width: _kBackGestureWidth,
child: new SizedBox(width: _kBackGestureWidth), top: 0.0,
bottom: 0.0,
child: new Listener(
onPointerDown: _handlePointerDown,
behavior: HitTestBehavior.translucent,
),
), ),
], ],
); );
......
...@@ -141,4 +141,48 @@ void main() { ...@@ -141,4 +141,48 @@ void main() {
// Page 1 is back where it started. // Page 1 is back where it started.
expect(widget1InitialTopLeft == widget1TransientTopLeft, true); expect(widget1InitialTopLeft == widget1TransientTopLeft, true);
}); });
}
\ No newline at end of file testWidgets('test only edge swipes work', (WidgetTester tester) async {
await tester.pumpWidget(
new WidgetsApp(
color: const Color(0xFFFFFFFF),
onGenerateRoute: (RouteSettings settings) {
return new CupertinoPageRoute<Null>(
settings: settings,
builder: (BuildContext context) {
final String pageNumber = settings.name == '/' ? "1" : "2";
return new Center(child: new Text('Page $pageNumber'));
}
);
},
),
);
tester.state<NavigatorState>(find.byType(Navigator)).pushNamed('/next');
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
// Page 2 covers page 1.
expect(find.text('Page 1'), findsNothing);
expect(find.text('Page 2'), isOnstage);
// Drag from the middle to the right.
TestGesture gesture = await tester.startGesture(const Offset(200.0, 200.0));
await gesture.moveBy(const Offset(300.0, 0.0));
await tester.pump();
// Nothing should happen.
expect(find.text('Page 1'), findsNothing);
expect(find.text('Page 2'), isOnstage);
// Now drag from the edge.
gesture = await tester.startGesture(const Offset(5.0, 200.0));
await gesture.moveBy(const Offset(300.0, 0.0));
await tester.pump();
// Page 1 is now visible.
expect(find.text('Page 1'), isOnstage);
expect(find.text('Page 2'), isOnstage);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment