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
d12f3599
Unverified
Commit
d12f3599
authored
Apr 29, 2019
by
xster
Committed by
GitHub
Apr 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix edge swiping and dropping back at starting point (#31623)
parent
727e7e82
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
route.dart
packages/flutter/lib/src/cupertino/route.dart
+3
-0
route_test.dart
packages/flutter/test/cupertino/route_test.dart
+69
-0
No files found.
packages/flutter/lib/src/cupertino/route.dart
View file @
d12f3599
...
...
@@ -621,6 +621,7 @@ class _CupertinoBackGestureController<T> {
animateForward
=
velocity
>
0
?
false
:
true
;
else
animateForward
=
controller
.
value
>
0.5
?
true
:
false
;
if
(
animateForward
)
{
// The closer the panel is to dismissing, the shorter the animation is.
// We want to cap the animation time, but we want to use a linear curve
...
...
@@ -652,6 +653,8 @@ class _CupertinoBackGestureController<T> {
controller
.
removeStatusListener
(
animationStatusCallback
);
};
controller
.
addStatusListener
(
animationStatusCallback
);
}
else
{
navigator
.
didStopUserGesture
();
}
}
}
...
...
packages/flutter/test/cupertino/route_test.dart
View file @
d12f3599
...
...
@@ -351,6 +351,10 @@ void main() {
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'route'
),
findsOneWidget
);
expect
(
find
.
text
(
'push'
),
findsNothing
);
expect
(
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
userGestureInProgress
,
false
,
);
});
testWidgets
(
'Fullscreen route animates correct transform values over time'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -536,6 +540,10 @@ void main() {
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
find
.
text
(
'1'
)).
dx
,
moreOrLessEquals
(-
233
,
epsilon:
1
));
expect
(
tester
.
getTopLeft
(
find
.
text
(
'2'
)).
dx
,
moreOrLessEquals
(
100
));
expect
(
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
userGestureInProgress
,
true
,
);
await
swipeGesture
.
moveBy
(
const
Offset
(
100
,
0
));
await
tester
.
pump
();
...
...
@@ -576,6 +584,10 @@ void main() {
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
find
.
text
(
'1'
)).
dx
,
moreOrLessEquals
(-
100
));
expect
(
tester
.
getTopLeft
(
find
.
text
(
'2'
)).
dx
,
moreOrLessEquals
(
500
));
expect
(
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
userGestureInProgress
,
true
,
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
expect
(
tester
.
getTopLeft
(
find
.
text
(
'1'
)).
dx
,
moreOrLessEquals
(-
19
,
epsilon:
1
));
...
...
@@ -585,6 +597,12 @@ void main() {
// Rate of change is slowing down.
expect
(
tester
.
getTopLeft
(
find
.
text
(
'1'
)).
dx
,
moreOrLessEquals
(-
4
,
epsilon:
1
));
expect
(
tester
.
getTopLeft
(
find
.
text
(
'2'
)).
dx
,
moreOrLessEquals
(
787
,
epsilon:
1
));
await
tester
.
pumpAndSettle
();
expect
(
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
userGestureInProgress
,
false
,
);
});
testWidgets
(
'Snapped drags forwards and backwards should signal didStart/StopUserGesture'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -667,12 +685,63 @@ void main() {
final
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Offset
(
5
,
200
));
// The width of the page.
await
gesture
.
moveBy
(
const
Offset
(
800
,
0
));
verify
(
navigatorObserver
.
didStartUserGesture
(
any
,
any
)).
called
(
1
);
await
gesture
.
up
();
await
tester
.
pump
();
expect
(
find
.
text
(
'Page 1'
),
isOnstage
);
expect
(
find
.
text
(
'Page 2'
),
findsNothing
);
verify
(
navigatorObserver
.
didPop
(
any
,
any
)).
called
(
1
);
verify
(
navigatorObserver
.
didStopUserGesture
()).
called
(
1
);
});
testWidgets
(
'test edge swipe then drop back at starting point works'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
CupertinoApp
(
navigatorObservers:
<
NavigatorObserver
>[
navigatorObserver
],
onGenerateRoute:
(
RouteSettings
settings
)
{
return
CupertinoPageRoute
<
void
>(
settings:
settings
,
builder:
(
BuildContext
context
)
{
final
String
pageNumber
=
settings
.
name
==
'/'
?
'1'
:
'2'
;
return
Center
(
child:
Text
(
'Page
$pageNumber
'
));
},
);
},
),
);
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
pushNamed
(
'/next'
);
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
find
.
text
(
'Page 1'
),
findsNothing
);
expect
(
find
.
text
(
'Page 2'
),
isOnstage
);
final
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Offset
(
5
,
200
));
// Move right a bit
await
gesture
.
moveBy
(
const
Offset
(
300
,
0
));
verify
(
navigatorObserver
.
didStartUserGesture
(
any
,
any
)).
called
(
1
);
expect
(
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
userGestureInProgress
,
true
,
);
await
tester
.
pump
();
// Move back to where we started.
await
gesture
.
moveBy
(
const
Offset
(-
300
,
0
));
await
gesture
.
up
();
await
tester
.
pump
();
expect
(
find
.
text
(
'Page 1'
),
findsNothing
);
expect
(
find
.
text
(
'Page 2'
),
isOnstage
);
verifyNever
(
navigatorObserver
.
didPop
(
any
,
any
));
verify
(
navigatorObserver
.
didStopUserGesture
()).
called
(
1
);
expect
(
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
)).
userGestureInProgress
,
false
,
);
});
}
...
...
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