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
09073a08
Unverified
Commit
09073a08
authored
Sep 24, 2019
by
Hans Muller
Committed by
GitHub
Sep 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rebuild modal routes when the value of userGestureInProgress changes (#41150)
parent
20d9a244
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
5 deletions
+101
-5
navigator.dart
packages/flutter/lib/src/widgets/navigator.dart
+17
-2
routes.dart
packages/flutter/lib/src/widgets/routes.dart
+12
-3
page_test.dart
packages/flutter/test/material/page_test.dart
+72
-0
No files found.
packages/flutter/lib/src/widgets/navigator.dart
View file @
09073a08
...
...
@@ -2239,10 +2239,25 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
route
.
dispose
();
}
int
get
_userGesturesInProgress
=>
_userGesturesInProgressCount
;
int
_userGesturesInProgressCount
=
0
;
set
_userGesturesInProgress
(
int
value
)
{
_userGesturesInProgressCount
=
value
;
userGestureInProgressNotifier
.
value
=
_userGesturesInProgress
>
0
;
}
/// Whether a route is currently being manipulated by the user, e.g.
/// as during an iOS back gesture.
bool
get
userGestureInProgress
=>
_userGesturesInProgress
>
0
;
int
_userGesturesInProgress
=
0
;
///
/// See also:
///
/// * [userGestureInProgressNotifier], which notifies its listeners if
/// the value of [userGestureInProgress] changes.
bool
get
userGestureInProgress
=>
userGestureInProgressNotifier
.
value
;
/// Notifies its listeners if the value of [userGestureInProgress] changes.
final
ValueNotifier
<
bool
>
userGestureInProgressNotifier
=
ValueNotifier
<
bool
>(
false
);
/// The navigator is being controlled by a user gesture.
///
...
...
packages/flutter/lib/src/widgets/routes.dart
View file @
09073a08
...
...
@@ -652,9 +652,18 @@ class _ModalScopeState<T> extends State<_ModalScope<T>> {
context
,
widget
.
route
.
animation
,
widget
.
route
.
secondaryAnimation
,
IgnorePointer
(
ignoring:
widget
.
route
.
navigator
.
userGestureInProgress
||
widget
.
route
.
animation
?.
status
==
AnimationStatus
.
reverse
,
// This additional AnimatedBuilder is include because if the
// value of the userGestureInProgressNotifier changes, it's
// only necessary to rebuild the IgnorePointer widget.
AnimatedBuilder
(
animation:
widget
.
route
.
navigator
.
userGestureInProgressNotifier
,
builder:
(
BuildContext
context
,
Widget
child
)
{
return
IgnorePointer
(
ignoring:
widget
.
route
.
navigator
.
userGestureInProgress
||
widget
.
route
.
animation
?.
status
==
AnimationStatus
.
reverse
,
child:
child
,
);
},
child:
child
,
),
);
...
...
packages/flutter/test/material/page_test.dart
View file @
09073a08
...
...
@@ -707,4 +707,76 @@ void main() {
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
pageScaffoldKey
)),
const
Offset
(
400
,
0
));
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
homeScaffoldKey
)).
dx
,
lessThan
(
0
));
});
testWidgets
(
'After a pop caused by a back-swipe, input reaches the exposed route'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/41024
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
);
final
ValueNotifier
<
bool
>
notifier
=
Navigator
.
of
(
homeScaffoldKey
.
currentContext
).
userGestureInProgressNotifier
;
expect
(
notifier
.
value
,
false
);
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
);
// Trigger the basic iOS back-swipe dismiss transition. Drag the pushed
// "page" route more than halfway across the screen and then release it.
final
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Offset
(
5
,
300
));
await
gesture
.
moveBy
(
const
Offset
(
500
,
0
));
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
pageScaffoldKey
)),
const
Offset
(
500
,
0
));
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
homeScaffoldKey
)).
dx
,
lessThan
(
0
));
expect
(
notifier
.
value
,
true
);
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
expect
(
notifier
.
value
,
false
);
expect
(
find
.
byKey
(
pageScaffoldKey
),
findsNothing
);
// The back-swipe dismiss pop transition has finished and input on the
// home page still works.
await
tester
.
tap
(
find
.
byKey
(
homeScaffoldKey
));
expect
(
homeTapCount
,
2
);
expect
(
pageTapCount
,
1
);
});
}
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