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
da34ae65
Commit
da34ae65
authored
Aug 20, 2016
by
Hans Muller
Committed by
GitHub
Aug 20, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ease Material route animations redux (#5509)
parent
789bfa42
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
8 deletions
+46
-8
heroes.dart
packages/flutter/lib/src/widgets/heroes.dart
+6
-7
heroes_test.dart
packages/flutter/test/widget/heroes_test.dart
+40
-1
No files found.
packages/flutter/lib/src/widgets/heroes.dart
View file @
da34ae65
...
...
@@ -447,7 +447,7 @@ class HeroController extends NavigatorObserver {
if
(
previousRoute
is
PageRoute
<
dynamic
>)
// could be null
_from
=
previousRoute
;
_to
=
route
;
_animation
=
new
CurvedAnimation
(
parent:
route
.
animation
,
curve:
Curves
.
fastOutSlowIn
)
;
_animation
=
route
.
animation
;
_checkForHeroQuest
();
}
}
...
...
@@ -461,7 +461,7 @@ class HeroController extends NavigatorObserver {
if
(
previousRoute
is
PageRoute
<
dynamic
>)
{
_to
=
previousRoute
;
_from
=
route
;
_animation
=
new
CurvedAnimation
(
parent:
route
.
animation
,
curve:
Curves
.
fastOutSlowIn
)
;
_animation
=
route
.
animation
;
_checkForHeroQuest
();
}
}
...
...
@@ -516,19 +516,18 @@ class HeroController extends NavigatorObserver {
Map
<
Object
,
HeroHandle
>
heroesTo
=
Hero
.
of
(
_to
.
subtreeContext
);
_to
.
offstage
=
false
;
Animation
<
double
>
animation
=
_animation
;
Animation
<
double
>
animation
=
_animation
;
// The route's animation.
Curve
curve
=
Curves
.
fastOutSlowIn
;
if
(
animation
.
status
==
AnimationStatus
.
reverse
)
{
animation
=
new
ReverseAnimation
(
animation
);
curve
=
new
Interval
(
animation
.
value
,
1.0
,
curve:
curve
);
}
animation
=
new
CurvedAnimation
(
parent:
animation
,
curve:
curve
);
_party
.
animate
(
heroesFrom
,
heroesTo
,
_getAnimationArea
(
navigator
.
context
));
_removeHeroesFromOverlay
();
_party
.
setAnimation
(
new
CurvedAnimation
(
parent:
animation
,
curve:
curve
));
_party
.
setAnimation
(
animation
);
for
(
_HeroQuestState
hero
in
_party
.
_heroes
)
{
hero
.
overlayEntry
=
_addHeroToOverlay
(
(
BuildContext
context
)
=>
hero
.
build
(
navigator
.
context
,
animation
),
...
...
packages/flutter/test/widget/heroes_test.dart
View file @
da34ae65
...
...
@@ -177,6 +177,46 @@ void main() {
await
tester
.
pump
(
new
Duration
(
seconds:
1
));
});
testWidgets
(
'Heroes animation is fastOutSlowIn'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
MaterialApp
(
routes:
routes
));
await
tester
.
tap
(
find
.
text
(
'two'
));
await
tester
.
pump
();
// begin navigation
// Expect the height of the secondKey Hero to vary from 100 to 150
// over duration and according to curve.
final
Duration
duration
=
const
Duration
(
milliseconds:
300
);
final
Curve
curve
=
Curves
.
fastOutSlowIn
;
final
double
initialHeight
=
tester
.
getSize
(
find
.
byKey
(
firstKey
)).
height
;
final
double
finalHeight
=
tester
.
getSize
(
find
.
byKey
(
secondKey
)).
height
;
final
double
deltaHeight
=
finalHeight
-
initialHeight
;
final
double
epsilon
=
0.001
;
await
tester
.
pump
(
duration
*
0.25
);
expect
(
tester
.
getSize
(
find
.
byKey
(
secondKey
)).
height
,
closeTo
(
curve
.
transform
(
0.25
)
*
deltaHeight
+
initialHeight
,
epsilon
)
);
await
tester
.
pump
(
duration
*
0.25
);
expect
(
tester
.
getSize
(
find
.
byKey
(
secondKey
)).
height
,
closeTo
(
curve
.
transform
(
0.50
)
*
deltaHeight
+
initialHeight
,
epsilon
)
);
await
tester
.
pump
(
duration
*
0.25
);
expect
(
tester
.
getSize
(
find
.
byKey
(
secondKey
)).
height
,
closeTo
(
curve
.
transform
(
0.75
)
*
deltaHeight
+
initialHeight
,
epsilon
)
);
await
tester
.
pump
(
duration
*
0.25
);
expect
(
tester
.
getSize
(
find
.
byKey
(
secondKey
)).
height
,
closeTo
(
curve
.
transform
(
1.0
)
*
deltaHeight
+
initialHeight
,
epsilon
)
);
});
testWidgets
(
'Heroes are not interactive'
,
(
WidgetTester
tester
)
async
{
List
<
String
>
log
=
<
String
>[];
...
...
@@ -246,5 +286,4 @@ void main() {
await
tester
.
tap
(
find
.
text
(
'bar'
));
expect
(
log
,
equals
(<
String
>[
'bar'
]));
});
}
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