Disable back gesture behind a flag until it's ready. (#5646)
Also added a regression test for the back gesture on iOS and android.
This commit is contained in:
parent
83bf5d10c0
commit
1a87d4b82c
@ -22,6 +22,9 @@ const double _kFloatingActionButtonMargin = 16.0; // TODO(hmuller): should be de
|
||||
const Duration _kFloatingActionButtonSegue = const Duration(milliseconds: 200);
|
||||
final Tween<double> _kFloatingActionButtonTurnTween = new Tween<double>(begin: -0.125, end: 0.0);
|
||||
|
||||
// iOS back gesture is in development. This flag will go away when it's ready
|
||||
// to ship.
|
||||
const bool _kBackGestureEnabled = false;
|
||||
const double _kBackGestureWidth = 20.0;
|
||||
|
||||
/// The Scaffold's appbar is the toolbar, bottom, and the "flexible space"
|
||||
@ -697,7 +700,9 @@ class ScaffoldState extends State<Scaffold> {
|
||||
NavigationGestureController _backGestureController;
|
||||
|
||||
bool _shouldHandleBackGesture() {
|
||||
return Theme.of(context).platform == TargetPlatform.iOS && Navigator.canPop(context);
|
||||
return _kBackGestureEnabled &&
|
||||
Theme.of(context).platform == TargetPlatform.iOS &&
|
||||
Navigator.canPop(context);
|
||||
}
|
||||
|
||||
void _handleDragStart(DragStartDetails details) {
|
||||
|
@ -93,6 +93,67 @@ void main() {
|
||||
expect(find.text('Overlay'), findsNothing);
|
||||
|
||||
expect(Navigator.canPop(containerKey1.currentContext), isFalse);
|
||||
});
|
||||
|
||||
testWidgets('Check back gesture works on iOS', (WidgetTester tester) async {
|
||||
GlobalKey containerKey1 = new GlobalKey();
|
||||
GlobalKey containerKey2 = new GlobalKey();
|
||||
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
|
||||
'/': (_) => new Scaffold(key: containerKey1, body: new Text('Home')),
|
||||
'/settings': (_) => new Scaffold(key: containerKey2, body: new Text('Settings')),
|
||||
};
|
||||
|
||||
await tester.pumpWidget(new MaterialApp(
|
||||
routes: routes,
|
||||
theme: new ThemeData(platform: TargetPlatform.iOS),
|
||||
));
|
||||
|
||||
Navigator.pushNamed(containerKey1.currentContext, '/settings');
|
||||
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
|
||||
expect(find.text('Home'), findsNothing);
|
||||
expect(find.text('Settings'), isOnstage);
|
||||
|
||||
// Drag from left edge to invoke the gesture.
|
||||
TestGesture gesture = await tester.startGesture(new Point(5.0, 100.0));
|
||||
await gesture.moveBy(new Offset(50.0, 0.0));
|
||||
await tester.pump();
|
||||
|
||||
// TODO(mpcomplete): back gesture disabled. Home should be onstage when
|
||||
// it is reenabled.
|
||||
expect(find.text('Home'), findsNothing);
|
||||
expect(find.text('Settings'), isOnstage);
|
||||
});
|
||||
|
||||
testWidgets('Check back gesture does nothing on android', (WidgetTester tester) async {
|
||||
GlobalKey containerKey1 = new GlobalKey();
|
||||
GlobalKey containerKey2 = new GlobalKey();
|
||||
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
|
||||
'/': (_) => new Scaffold(key: containerKey1, body: new Text('Home')),
|
||||
'/settings': (_) => new Scaffold(key: containerKey2, body: new Text('Settings')),
|
||||
};
|
||||
|
||||
await tester.pumpWidget(new MaterialApp(
|
||||
routes: routes,
|
||||
theme: new ThemeData(platform: TargetPlatform.android),
|
||||
));
|
||||
|
||||
Navigator.pushNamed(containerKey1.currentContext, '/settings');
|
||||
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
|
||||
expect(find.text('Home'), findsNothing);
|
||||
expect(find.text('Settings'), isOnstage);
|
||||
|
||||
// Drag from left edge to invoke the gesture.
|
||||
TestGesture gesture = await tester.startGesture(new Point(5.0, 100.0));
|
||||
await gesture.moveBy(new Offset(50.0, 0.0));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Home'), findsNothing);
|
||||
expect(find.text('Settings'), isOnstage);
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user