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
044ecf54
Commit
044ecf54
authored
Mar 27, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
toStrings for Animations and Animatables
parent
2e5ae373
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
3 deletions
+101
-3
animations.dart
packages/flutter/lib/src/animation/animations.dart
+44
-2
curves.dart
packages/flutter/lib/src/animation/curves.dart
+42
-0
tween.dart
packages/flutter/lib/src/animation/tween.dart
+15
-1
No files found.
packages/flutter/lib/src/animation/animations.dart
View file @
044ecf54
...
...
@@ -28,6 +28,9 @@ class _AlwaysCompleteAnimation extends Animation<double> {
@override
double
get
value
=>
1.0
;
@override
String
toString
()
=>
'kAlwaysCompleteAnimation'
;
}
/// An animation that is always complete.
...
...
@@ -57,6 +60,9 @@ class _AlwaysDismissedAnimation extends Animation<double> {
@override
double
get
value
=>
0.0
;
@override
String
toString
()
=>
'kAlwaysDismissedAnimation'
;
}
/// An animation that is always dismissed.
...
...
@@ -96,6 +102,11 @@ class AlwaysStoppedAnimation<T> extends Animation<T> {
@override
AnimationStatus
get
status
=>
AnimationStatus
.
forward
;
@override
String
toStringDetails
()
{
return
'
${super.toStringDetails()}
$value
; paused'
;
}
}
/// Implements most of the [Animation] interface, by deferring its behavior to a
...
...
@@ -195,6 +206,13 @@ class ProxyAnimation extends Animation<double>
@override
double
get
value
=>
_parent
!=
null
?
_parent
.
value
:
_value
;
@override
String
toString
()
{
if
(
parent
==
null
)
return
'
$runtimeType
(null;
${super.toStringDetails()}
${value.toStringAsFixed(3)}
)'
;
return
'
$parent
\
u27A9
$runtimeType
'
;
}
}
/// An animation that is the reverse of another animation.
...
...
@@ -251,6 +269,11 @@ class ReverseAnimation extends Animation<double>
case
AnimationStatus
.
dismissed
:
return
AnimationStatus
.
completed
;
}
}
@override
String
toString
()
{
return
'
$parent
\
u27AA
$runtimeType
'
;
}
}
/// An animation that applies a curve to another animation.
...
...
@@ -317,10 +340,13 @@ class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<do
}
}
bool
get
_useForwardCurve
{
return
reverseCurve
==
null
||
(
_curveDirection
??
parent
.
status
)
!=
AnimationStatus
.
reverse
;
}
@override
double
get
value
{
final
bool
useForwardCurve
=
reverseCurve
==
null
||
(
_curveDirection
??
parent
.
status
)
!=
AnimationStatus
.
reverse
;
Curve
activeCurve
=
useForwardCurve
?
curve
:
reverseCurve
;
Curve
activeCurve
=
_useForwardCurve
?
curve
:
reverseCurve
;
double
t
=
parent
.
value
;
if
(
activeCurve
==
null
)
...
...
@@ -331,6 +357,15 @@ class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<do
}
return
activeCurve
.
transform
(
t
);
}
@override
String
toString
()
{
if
(
reverseCurve
==
null
)
return
'
$parent
\
u27A9
$curve
'
;
if
(
_useForwardCurve
)
return
'
$parent
\
u27A9
$curve
\
u2092
\
u2099/
$reverseCurve
'
;
return
'
$parent
\
u27A9
$curve
/
$reverseCurve
\
u2092
\
u2099'
;
}
}
enum
_TrainHoppingMode
{
minimize
,
maximize
}
...
...
@@ -439,4 +474,11 @@ class TrainHoppingAnimation extends Animation<double>
_nextTrain
=
null
;
}
}
@override
String
toString
()
{
if
(
_nextTrain
!=
null
)
return
'
$currentTrain
\
u27A9
$runtimeType
(next:
$_nextTrain
)'
;
return
'
$currentTrain
\
u27A9
$runtimeType
(no next)'
;
}
}
packages/flutter/lib/src/animation/curves.dart
View file @
044ecf54
...
...
@@ -28,6 +28,11 @@ abstract class Curve {
/// Returns a new curve that is the reversed inversion of this one.
/// This is often useful as the reverseCurve of an [Animation].
Curve
get
flipped
=>
new
FlippedCurve
(
this
);
@override
String
toString
()
{
return
'
$runtimeType
'
;
}
}
/// The identity map over the unit interval.
...
...
@@ -49,6 +54,11 @@ class SawTooth extends Curve {
t
*=
count
;
return
t
-
t
.
truncateToDouble
();
}
@override
String
toString
()
{
return
'
$runtimeType
(
$count
)'
;
}
}
/// A curve that is 0.0 until start, then curved from 0.0 to 1.0 at end, then 1.0.
...
...
@@ -76,6 +86,13 @@ class Interval extends Curve {
return
t
;
return
curve
.
transform
(
t
);
}
@override
String
toString
()
{
if
(
curve
is
!
Linear
)
return
'
$runtimeType
(
$start
\
u22EF
$end
)
\
u27A9
$curve
'
;
return
'
$runtimeType
(
$start
\
u22EF
$end
)'
;
}
}
/// A cubic polynomial mapping of the unit interval.
...
...
@@ -102,6 +119,11 @@ class Cubic extends Curve {
end
=
midpoint
;
}
}
@override
String
toString
()
{
return
'
$runtimeType
(
${a.toStringAsFixed(2)}
,
${b.toStringAsFixed(2)}
,
${c.toStringAsFixed(2)}
,
${d.toStringAsFixed(2)}
)'
;
}
}
double
_bounce
(
double
t
)
{
...
...
@@ -126,6 +148,11 @@ class FlippedCurve extends Curve {
@override
double
transform
(
double
t
)
=>
1.0
-
curve
.
transform
(
1.0
-
t
);
@override
String
toString
()
{
return
'
$runtimeType
(
$curve
)'
;
}
}
/// An oscillating curve that grows in magnitude.
...
...
@@ -173,6 +200,11 @@ class ElasticInCurve extends Curve {
t
=
t
-
1.0
;
return
-
math
.
pow
(
2.0
,
10.0
*
t
)
*
math
.
sin
((
t
-
s
)
*
(
math
.
PI
*
2.0
)
/
period
);
}
@override
String
toString
()
{
return
'
$runtimeType
(
$period
)'
;
}
}
/// An oscillating curve that shrinks in magnitude while overshooting its bounds.
...
...
@@ -186,6 +218,11 @@ class ElasticOutCurve extends Curve {
double
s
=
period
/
4.0
;
return
math
.
pow
(
2.0
,
-
10
*
t
)
*
math
.
sin
((
t
-
s
)
*
(
math
.
PI
*
2.0
)
/
period
)
+
1.0
;
}
@override
String
toString
()
{
return
'
$runtimeType
(
$period
)'
;
}
}
/// An oscillating curve that grows and then shrinks in magnitude while overshooting its bounds.
...
...
@@ -203,6 +240,11 @@ class ElasticInOutCurve extends Curve {
else
return
math
.
pow
(
2.0
,
-
10.0
*
t
)
*
math
.
sin
((
t
-
s
)
*
(
math
.
PI
*
2.0
)
/
period
)
*
0.5
+
1.0
;
}
@override
String
toString
()
{
return
'
$runtimeType
(
$period
)'
;
}
}
/// A collection of common animation curves.
...
...
packages/flutter/lib/src/animation/tween.dart
View file @
044ecf54
...
...
@@ -33,7 +33,6 @@ abstract class Animatable<T> {
class
_AnimatedEvaluation
<
T
>
extends
Animation
<
T
>
with
AnimationWithParentMixin
<
double
>
{
_AnimatedEvaluation
(
this
.
parent
,
this
.
_evaluatable
);
/// The animation from which this value is derived.
@override
final
Animation
<
double
>
parent
;
...
...
@@ -41,6 +40,16 @@ class _AnimatedEvaluation<T> extends Animation<T> with AnimationWithParentMixin<
@override
T
get
value
=>
_evaluatable
.
evaluate
(
parent
);
@override
String
toString
()
{
return
'
$parent
\
u27A9
$_evaluatable
'
;
}
@override
String
toStringDetails
()
{
return
'
${super.toStringDetails()}
$_evaluatable
'
;
}
}
class
_ChainedEvaluation
<
T
>
extends
Animatable
<
T
>
{
...
...
@@ -54,6 +63,11 @@ class _ChainedEvaluation<T> extends Animatable<T> {
double
value
=
_parent
.
evaluate
(
animation
);
return
_evaluatable
.
evaluate
(
new
AlwaysStoppedAnimation
<
double
>(
value
));
}
@override
String
toString
()
{
return
'
$_parent
\
u27A9
$_evaluatable
'
;
}
}
/// A linear interpolation between a beginning and ending value.
...
...
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