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
819bb539
Commit
819bb539
authored
Apr 12, 2017
by
xster
Committed by
GitHub
Apr 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slight efficiency improvement on all page transitions (#9356)
Remove intermediate animation listener
parent
9f34e2e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
51 deletions
+43
-51
page.dart
packages/flutter/lib/src/cupertino/page.dart
+19
-28
page.dart
packages/flutter/lib/src/material/page.dart
+24
-23
No files found.
packages/flutter/lib/src/cupertino/page.dart
View file @
819bb539
...
...
@@ -20,14 +20,17 @@ final FractionalOffsetTween _kMiddleLeftTween = new FractionalOffsetTween(
end:
const
FractionalOffset
(-
1.0
/
3.0
,
0.0
),
);
// Fractional offset from offscreen below to fully on screen.
final
FractionalOffsetTween
_kBottomUpTween
=
new
FractionalOffsetTween
(
begin:
FractionalOffset
.
bottomLeft
,
end:
FractionalOffset
.
topLeft
,
);
/// Provides the native iOS page transition animation.
///
/// Takes in a page widget and a route animation from a [TransitionRoute] and produces an
/// AnimatedWidget wrapping that animates the page transition.
///
/// The page slides in from the right and exits in reverse. It also shifts to the left in
/// a parallax motion when another page enters to cover it.
class
CupertinoPageTransition
extends
Animated
Widget
{
class
CupertinoPageTransition
extends
Stateless
Widget
{
CupertinoPageTransition
({
Key
key
,
// Linear route animation from 0.0 to 1.0 when this screen is being pushed.
...
...
@@ -55,13 +58,7 @@ class CupertinoPageTransition extends AnimatedWidget {
reverseCurve:
Curves
.
easeIn
,
)
),
super
(
key:
key
,
// Trigger a rebuild whenever any of the 2 animation route happens.
listenable:
new
Listenable
.
merge
(
<
Listenable
>[
incomingRouteAnimation
,
outgoingRouteAnimation
]
),
);
super
(
key:
key
);
// When this page is coming in to cover another page.
final
Animation
<
FractionalOffset
>
_incomingPositionAnimation
;
...
...
@@ -91,32 +88,26 @@ class CupertinoPageTransition extends AnimatedWidget {
/// Transitions used for summoning fullscreen dialogs in iOS such as creating a new
/// calendar event etc by bringing in the next screen from the bottom.
class
CupertinoFullscreenDialogTransition
extends
Animated
Widget
{
class
CupertinoFullscreenDialogTransition
extends
Stateless
Widget
{
CupertinoFullscreenDialogTransition
({
Key
key
,
@required
Animation
<
double
>
animation
,
@required
this
.
child
,
})
:
super
(
key:
key
,
listenable:
_kBottomUpTween
.
animate
(
new
CurvedAnimation
(
parent:
animation
,
curve:
Curves
.
easeInOut
,
)
),
);
static
final
FractionalOffsetTween
_kBottomUpTween
=
new
FractionalOffsetTween
(
begin:
FractionalOffset
.
bottomLeft
,
end:
FractionalOffset
.
topLeft
,
);
})
:
_positionAnimation
=
_kBottomUpTween
.
animate
(
new
CurvedAnimation
(
parent:
animation
,
curve:
Curves
.
easeInOut
,
)
),
super
(
key:
key
);
final
Animation
<
FractionalOffset
>
_positionAnimation
;
final
Widget
child
;
@override
Widget
build
(
BuildContext
context
)
{
return
new
SlideTransition
(
position:
listenable
,
position:
_positionAnimation
,
child:
child
,
);
}
...
...
packages/flutter/lib/src/material/page.dart
View file @
819bb539
...
...
@@ -3,43 +3,44 @@
// found in the LICENSE file.
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'theme.dart'
;
// Fractional offset from 1/4 screen below the top to fully on screen.
final
FractionalOffsetTween
_kBottomUpTween
=
new
FractionalOffsetTween
(
begin:
const
FractionalOffset
(
0.0
,
0.25
),
end:
FractionalOffset
.
topLeft
);
// Used for Android and Fuchsia.
class
_MountainViewPageTransition
extends
Animated
Widget
{
class
_MountainViewPageTransition
extends
Stateless
Widget
{
_MountainViewPageTransition
({
Key
key
,
this
.
routeAnimation
,
this
.
child
,
})
:
super
(
key:
key
,
listenable:
_kTween
.
animate
(
new
CurvedAnimation
(
parent:
routeAnimation
,
// The route's linear 0.0 - 1.0 animation.
curve:
Curves
.
fastOutSlowIn
)
));
static
final
FractionalOffsetTween
_kTween
=
new
FractionalOffsetTween
(
begin:
const
FractionalOffset
(
0.0
,
0.25
),
end:
FractionalOffset
.
topLeft
);
@required
Animation
<
double
>
routeAnimation
,
@required
this
.
child
,
})
:
_positionAnimation
=
_kBottomUpTween
.
animate
(
new
CurvedAnimation
(
parent:
routeAnimation
,
// The route's linear 0.0 - 1.0 animation.
curve:
Curves
.
fastOutSlowIn
,
)),
_opacityAnimation
=
new
CurvedAnimation
(
parent:
routeAnimation
,
curve:
Curves
.
easeIn
,
// Eyeballed from other Material apps.
),
super
(
key:
key
);
final
Animation
<
FractionalOffset
>
_positionAnimation
;
final
Animation
<
double
>
_opacityAnimation
;
final
Widget
child
;
final
Animation
<
double
>
routeAnimation
;
@override
Widget
build
(
BuildContext
context
)
{
// TODO(ianh): tell the transform to be un-transformed for hit testing
return
new
SlideTransition
(
position:
listenable
,
position:
_positionAnimation
,
child:
new
FadeTransition
(
opacity:
new
CurvedAnimation
(
parent:
routeAnimation
,
curve:
Curves
.
easeIn
,
// Eyeballed from other Material apps.
),
opacity:
_opacityAnimation
,
child:
child
,
),
);
...
...
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