Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0f00f424
Unverified
Commit
0f00f424
authored
Sep 16, 2019
by
Hans Muller
Committed by
GitHub
Sep 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ModalRoutes ignore input when a (cupertino) pop transition is underway (#40466)
parent
25ac81ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
160 additions
and
3 deletions
+160
-3
routes.dart
packages/flutter/lib/src/widgets/routes.dart
+2
-1
route_test.dart
packages/flutter/test/cupertino/route_test.dart
+75
-1
page_test.dart
packages/flutter/test/material/page_test.dart
+83
-1
No files found.
packages/flutter/lib/src/widgets/routes.dart
View file @
0f00f424
...
...
@@ -654,7 +654,8 @@ class _ModalScopeState<T> extends State<_ModalScope<T>> {
widget
.
route
.
animation
,
widget
.
route
.
secondaryAnimation
,
IgnorePointer
(
ignoring:
widget
.
route
.
animation
?.
status
==
AnimationStatus
.
reverse
,
ignoring:
widget
.
route
.
navigator
.
userGestureInProgress
||
widget
.
route
.
animation
?.
status
==
AnimationStatus
.
reverse
,
child:
child
,
),
);
...
...
packages/flutter/test/cupertino/route_test.dart
View file @
0f00f424
...
...
@@ -347,7 +347,18 @@ void main() {
tester
.
getTopLeft
(
find
.
ancestor
(
of:
find
.
text
(
'route'
),
matching:
find
.
byType
(
CupertinoPageScaffold
))).
dx
,
moreOrLessEquals
(
798
,
epsilon:
1
),
);
await
tester
.
tap
(
find
.
text
(
'push'
));
// Use the navigator to push a route instead of tapping the 'push' button.
// The topmost route (the one that's animating away), ignores input while
// the pop is underway because route.navigator.userGestureInProgress.
Navigator
.
push
<
void
>(
scaffoldKey
.
currentContext
,
CupertinoPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
const
CupertinoPageScaffold
(
child:
Center
(
child:
Text
(
'route'
)),
);
},
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'route'
),
findsOneWidget
);
expect
(
find
.
text
(
'push'
),
findsNothing
);
...
...
@@ -816,6 +827,69 @@ void main() {
0x7A000000
,
);
});
testWidgets
(
'During back swipe the route ignores input'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/39989
final
GlobalKey
homeScaffoldKey
=
GlobalKey
();
final
GlobalKey
pageScaffoldKey
=
GlobalKey
();
int
homeTapCount
=
0
;
int
pageTapCount
=
0
;
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
CupertinoPageScaffold
(
key:
homeScaffoldKey
,
child:
GestureDetector
(
onTap:
()
{
homeTapCount
+=
1
;
}
),
),
),
);
await
tester
.
tap
(
find
.
byKey
(
homeScaffoldKey
));
expect
(
homeTapCount
,
1
);
expect
(
pageTapCount
,
0
);
Navigator
.
push
<
void
>(
homeScaffoldKey
.
currentContext
,
CupertinoPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
CupertinoPageScaffold
(
key:
pageScaffoldKey
,
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
16
),
child:
GestureDetector
(
onTap:
()
{
pageTapCount
+=
1
;
}
),
),
);
},
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
byKey
(
pageScaffoldKey
));
expect
(
homeTapCount
,
1
);
expect
(
pageTapCount
,
1
);
// Start the basic iOS back-swipe dismiss transition. Drag the pushed
// "page" route halfway across the screen. The underlying "home" will
// start sliding in from the left.
final
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Offset
(
5
,
300
));
await
gesture
.
moveBy
(
const
Offset
(
400
,
0
));
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
pageScaffoldKey
)),
const
Offset
(
400
,
0
));
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
homeScaffoldKey
)).
dx
,
lessThan
(
0
));
// Tapping on the "page" route doesn't trigger the GestureDetector because
// it's being dragged.
await
tester
.
tap
(
find
.
byKey
(
pageScaffoldKey
));
expect
(
homeTapCount
,
1
);
expect
(
pageTapCount
,
1
);
});
}
class
MockNavigatorObserver
extends
Mock
implements
NavigatorObserver
{}
packages/flutter/test/material/page_test.dart
View file @
0f00f424
...
...
@@ -620,9 +620,91 @@ void main() {
tester
.
getTopLeft
(
find
.
ancestor
(
of:
find
.
text
(
'route'
),
matching:
find
.
byType
(
Scaffold
))).
dx
,
moreOrLessEquals
(
798
,
epsilon:
1
),
);
await
tester
.
tap
(
find
.
text
(
'push'
));
// Use the navigator to push a route instead of tapping the 'push' button.
// The topmost route (the one that's animating away), ignores input while
// the pop is underway because route.navigator.userGestureInProgress.
Navigator
.
push
<
void
>(
scaffoldKey
.
currentContext
,
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
const
Scaffold
(
body:
Center
(
child:
Text
(
'route'
)),
);
},
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'route'
),
findsOneWidget
);
expect
(
find
.
text
(
'push'
),
findsNothing
);
});
testWidgets
(
'During back swipe the route ignores input'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/39989
final
GlobalKey
homeScaffoldKey
=
GlobalKey
();
final
GlobalKey
pageScaffoldKey
=
GlobalKey
();
int
homeTapCount
=
0
;
int
pageTapCount
=
0
;
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
iOS
),
home:
Scaffold
(
key:
homeScaffoldKey
,
body:
GestureDetector
(
onTap:
()
{
homeTapCount
+=
1
;
}
),
),
),
);
await
tester
.
tap
(
find
.
byKey
(
homeScaffoldKey
));
expect
(
homeTapCount
,
1
);
expect
(
pageTapCount
,
0
);
Navigator
.
push
<
void
>(
homeScaffoldKey
.
currentContext
,
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
Scaffold
(
key:
pageScaffoldKey
,
appBar:
AppBar
(
title:
const
Text
(
'Page'
)),
body:
Padding
(
padding:
const
EdgeInsets
.
all
(
16
),
child:
GestureDetector
(
onTap:
()
{
pageTapCount
+=
1
;
}
),
),
);
},
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
byKey
(
pageScaffoldKey
));
expect
(
homeTapCount
,
1
);
expect
(
pageTapCount
,
1
);
// Start the basic iOS back-swipe dismiss transition. Drag the pushed
// "page" route halfway across the screen. The underlying "home" will
// start sliding in from the left.
final
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Offset
(
5
,
300
));
await
gesture
.
moveBy
(
const
Offset
(
400
,
0
));
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
pageScaffoldKey
)),
const
Offset
(
400
,
0
));
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
homeScaffoldKey
)).
dx
,
lessThan
(
0
));
// Tapping on the "page" route doesn't trigger the GestureDetector because
// it's being dragged.
await
tester
.
tap
(
find
.
byKey
(
pageScaffoldKey
));
expect
(
homeTapCount
,
1
);
expect
(
pageTapCount
,
1
);
// Tapping the "page" route's back button doesn't do anything either.
await
tester
.
tap
(
find
.
byTooltip
(
'Back'
));
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
pageScaffoldKey
)),
const
Offset
(
400
,
0
));
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
homeScaffoldKey
)).
dx
,
lessThan
(
0
));
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment