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
3f82552d
Commit
3f82552d
authored
Oct 05, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improves names of animation classes
Fixes #1170
parent
bc9d004c
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
149 additions
and
167 deletions
+149
-167
feed.dart
examples/fitness/lib/feed.dart
+4
-4
stock_home.dart
examples/stocks/lib/stock_home.dart
+4
-4
progress_indicator.dart
examples/widgets/progress_indicator.dart
+8
-8
animation.dart
packages/flutter/lib/animation.dart
+1
-1
animated_value.dart
packages/flutter/lib/src/animation/animated_value.dart
+15
-33
performance.dart
packages/flutter/lib/src/animation/performance.dart
+47
-47
simulation_stepper.dart
packages/flutter/lib/src/animation/simulation_stepper.dart
+1
-1
radial_reaction.dart
packages/flutter/lib/src/painting/radial_reaction.dart
+4
-4
toggleable.dart
packages/flutter/lib/src/rendering/toggleable.dart
+4
-4
animated_component.dart
packages/flutter/lib/src/widgets/animated_component.dart
+7
-7
animated_container.dart
packages/flutter/lib/src/widgets/animated_container.dart
+3
-3
dialog.dart
packages/flutter/lib/src/widgets/dialog.dart
+1
-1
dismissable.dart
packages/flutter/lib/src/widgets/dismissable.dart
+7
-7
drag_target.dart
packages/flutter/lib/src/widgets/drag_target.dart
+1
-1
drawer.dart
packages/flutter/lib/src/widgets/drawer.dart
+5
-5
ink_well.dart
packages/flutter/lib/src/widgets/ink_well.dart
+2
-2
navigator.dart
packages/flutter/lib/src/widgets/navigator.dart
+14
-14
popup_menu.dart
packages/flutter/lib/src/widgets/popup_menu.dart
+4
-4
progress_indicator.dart
packages/flutter/lib/src/widgets/progress_indicator.dart
+4
-4
snack_bar.dart
packages/flutter/lib/src/widgets/snack_bar.dart
+1
-1
tabs.dart
packages/flutter/lib/src/widgets/tabs.dart
+4
-4
transitions.dart
packages/flutter/lib/src/widgets/transitions.dart
+8
-8
No files found.
examples/fitness/lib/feed.dart
View file @
3f82552d
...
...
@@ -60,7 +60,7 @@ class FeedFragment extends StatefulComponent {
class
FeedFragmentState
extends
State
<
FeedFragment
>
{
FitnessMode
_fitnessMode
=
FitnessMode
.
feed
;
AnimationStatus
_snackBarStatus
=
Animation
Status
.
dismissed
;
PerformanceStatus
_snackBarStatus
=
Performance
Status
.
dismissed
;
bool
_isShowingSnackBar
=
false
;
void
_handleFitnessModeChange
(
FitnessMode
value
)
{
...
...
@@ -126,7 +126,7 @@ class FeedFragmentState extends State<FeedFragment> {
setState
(()
{
_undoItem
=
item
;
_isShowingSnackBar
=
true
;
_snackBarStatus
=
Animation
Status
.
forward
;
_snackBarStatus
=
Performance
Status
.
forward
;
});
}
...
...
@@ -207,13 +207,13 @@ class FeedFragmentState extends State<FeedFragment> {
}
Widget
buildSnackBar
()
{
if
(
_snackBarStatus
==
Animation
Status
.
dismissed
)
if
(
_snackBarStatus
==
Performance
Status
.
dismissed
)
return
null
;
return
new
SnackBar
(
showing:
_isShowingSnackBar
,
content:
new
Text
(
"Item deleted."
),
actions:
[
new
SnackBarAction
(
label:
"UNDO"
,
onPressed:
_handleUndo
)],
onDismissed:
()
{
setState
(()
{
_snackBarStatus
=
Animation
Status
.
dismissed
;
});
}
onDismissed:
()
{
setState
(()
{
_snackBarStatus
=
Performance
Status
.
dismissed
;
});
}
);
}
...
...
examples/stocks/lib/stock_home.dart
View file @
3f82552d
...
...
@@ -25,7 +25,7 @@ class StockHomeState extends State<StockHome> {
bool
_isSearching
=
false
;
String
_searchQuery
;
AnimationStatus
_snackBarStatus
=
Animation
Status
.
dismissed
;
PerformanceStatus
_snackBarStatus
=
Performance
Status
.
dismissed
;
bool
_isSnackBarShowing
=
false
;
void
_handleSearchBegin
()
{
...
...
@@ -224,20 +224,20 @@ class StockHomeState extends State<StockHome> {
GlobalKey
snackBarKey
=
new
GlobalKey
(
label:
'snackbar'
);
Widget
buildSnackBar
()
{
if
(
_snackBarStatus
==
Animation
Status
.
dismissed
)
if
(
_snackBarStatus
==
Performance
Status
.
dismissed
)
return
null
;
return
new
SnackBar
(
showing:
_isSnackBarShowing
,
content:
new
Text
(
"Stock purchased!"
),
actions:
[
new
SnackBarAction
(
label:
"UNDO"
,
onPressed:
_handleUndo
)],
onDismissed:
()
{
setState
(()
{
_snackBarStatus
=
Animation
Status
.
dismissed
;
});
}
onDismissed:
()
{
setState
(()
{
_snackBarStatus
=
Performance
Status
.
dismissed
;
});
}
);
}
void
_handleStockPurchased
()
{
setState
(()
{
_isSnackBarShowing
=
true
;
_snackBarStatus
=
Animation
Status
.
forward
;
_snackBarStatus
=
Performance
Status
.
forward
;
});
}
...
...
examples/widgets/progress_indicator.dart
View file @
3f82552d
...
...
@@ -13,7 +13,7 @@ class ProgressIndicatorApp extends StatefulComponent {
class
ProgressIndicatorAppState
extends
State
<
ProgressIndicatorApp
>
{
void
initState
()
{
super
.
initState
();
valueAnimation
=
new
Value
Animation
<
double
>()
valueAnimation
=
new
Value
Performance
<
double
>()
..
duration
=
const
Duration
(
milliseconds:
1500
)
..
variable
=
new
AnimatedValue
<
double
>(
0.0
,
...
...
@@ -22,15 +22,15 @@ class ProgressIndicatorAppState extends State<ProgressIndicatorApp> {
reverseCurve:
ease
,
interval:
new
Interval
(
0.0
,
0.9
)
);
valueAnimation
.
addStatusListener
((
Animation
Status
status
)
{
if
(
status
==
AnimationStatus
.
dismissed
||
status
==
Animation
Status
.
completed
)
valueAnimation
.
addStatusListener
((
Performance
Status
status
)
{
if
(
status
==
PerformanceStatus
.
dismissed
||
status
==
Performance
Status
.
completed
)
reverseValueAnimationDirection
();
});
valueAnimation
.
play
(
valueAnimationDirection
);
}
Value
Animation
<
double
>
valueAnimation
;
Direction
valueAnimationDirection
=
Direction
.
forward
;
Value
Performance
<
double
>
valueAnimation
;
AnimationDirection
valueAnimationDirection
=
Animation
Direction
.
forward
;
void
handleTap
()
{
setState
(()
{
...
...
@@ -43,9 +43,9 @@ class ProgressIndicatorAppState extends State<ProgressIndicatorApp> {
}
void
reverseValueAnimationDirection
()
{
valueAnimationDirection
=
(
valueAnimationDirection
==
Direction
.
forward
)
?
Direction
.
reverse
:
Direction
.
forward
;
valueAnimationDirection
=
(
valueAnimationDirection
==
Animation
Direction
.
forward
)
?
Animation
Direction
.
reverse
:
Animation
Direction
.
forward
;
valueAnimation
.
play
(
valueAnimationDirection
);
}
...
...
packages/flutter/lib/animation.dart
View file @
3f82552d
...
...
@@ -8,7 +8,7 @@
library
animation
;
export
'src/animation/animated_value.dart'
;
export
'src/animation/
animation_
performance.dart'
;
export
'src/animation/performance.dart'
;
export
'src/animation/clamped_simulation.dart'
;
export
'src/animation/curves.dart'
;
export
'src/animation/forces.dart'
;
...
...
packages/flutter/lib/src/animation/animated_value.dart
View file @
3f82552d
...
...
@@ -7,7 +7,7 @@ import 'dart:sky' show Color, Rect;
import
'package:sky/src/animation/curves.dart'
;
/// The direction in which an animation is running
enum
Direction
{
enum
Animation
Direction
{
/// The animation is running from beginning to end
forward
,
...
...
@@ -17,11 +17,11 @@ enum Direction {
/// An interface describing a variable that changes as an animation progresses.
///
/// Animat
edVariables, by convention, must be cheap to create. This allows them to be used in
/// build functions in Widgets.
abstract
class
Animat
edVari
able
{
/// Animat
able objects, by convention, must be cheap to create. This allows them
///
to be used in
build functions in Widgets.
abstract
class
Animatable
{
/// Update the variable to a given time in an animation that is running in the given direction
void
setProgress
(
double
t
,
Direction
direction
);
void
setProgress
(
double
t
,
Animation
Direction
direction
);
String
toString
();
}
...
...
@@ -53,7 +53,7 @@ class AnimationTiming {
Curve
reverseCurve
;
/// Applies this timing to the given animation clock value in the given direction
double
transform
(
double
t
,
Direction
direction
)
{
double
transform
(
double
t
,
Animation
Direction
direction
)
{
Interval
interval
=
_getInterval
(
direction
);
if
(
interval
!=
null
)
t
=
interval
.
transform
(
t
);
...
...
@@ -65,19 +65,19 @@ class AnimationTiming {
return
_applyCurve
(
t
,
direction
);
}
Interval
_getInterval
(
Direction
direction
)
{
if
(
direction
==
Direction
.
forward
||
reverseInterval
==
null
)
Interval
_getInterval
(
Animation
Direction
direction
)
{
if
(
direction
==
Animation
Direction
.
forward
||
reverseInterval
==
null
)
return
interval
;
return
reverseInterval
;
}
Curve
_getCurve
(
Direction
direction
)
{
if
(
direction
==
Direction
.
forward
||
reverseCurve
==
null
)
Curve
_getCurve
(
Animation
Direction
direction
)
{
if
(
direction
==
Animation
Direction
.
forward
||
reverseCurve
==
null
)
return
curve
;
return
reverseCurve
;
}
double
_applyCurve
(
double
t
,
Direction
direction
)
{
double
_applyCurve
(
double
t
,
Animation
Direction
direction
)
{
Curve
curve
=
_getCurve
(
direction
);
if
(
curve
==
null
)
return
t
;
...
...
@@ -86,7 +86,7 @@ class AnimationTiming {
}
/// An animated variable with a concrete type
class
AnimatedValue
<
T
extends
dynamic
>
extends
AnimationTiming
implements
Animat
edVari
able
{
class
AnimatedValue
<
T
extends
dynamic
>
extends
AnimationTiming
implements
Animatable
{
AnimatedValue
(
this
.
begin
,
{
this
.
end
,
Interval
interval
,
Interval
reverseInterval
,
Curve
curve
,
Curve
reverseCurve
})
:
super
(
interval:
interval
,
reverseInterval:
reverseInterval
,
curve:
curve
,
reverseCurve:
reverseCurve
)
{
value
=
begin
;
...
...
@@ -105,7 +105,7 @@ class AnimatedValue<T extends dynamic> extends AnimationTiming implements Animat
T
lerp
(
double
t
)
=>
begin
+
(
end
-
begin
)
*
t
;
/// Updates the value of this variable according to the given animation clock value and direction
void
setProgress
(
double
t
,
Direction
direction
)
{
void
setProgress
(
double
t
,
Animation
Direction
direction
)
{
if
(
end
!=
null
)
{
t
=
transform
(
t
,
direction
);
if
(
t
==
0.0
)
...
...
@@ -120,24 +120,6 @@ class AnimatedValue<T extends dynamic> extends AnimationTiming implements Animat
String
toString
()
=>
'AnimatedValue(begin=
$begin
, end=
$end
, value=
$value
)'
;
}
/// A list of animated variables
class
AnimatedList
extends
AnimationTiming
implements
AnimatedVariable
{
/// The list of variables contained in the list
List
<
AnimatedVariable
>
variables
;
AnimatedList
(
this
.
variables
,
{
Interval
interval
,
Interval
reverseInterval
,
Curve
curve
,
Curve
reverseCurve
})
:
super
(
interval:
interval
,
reverseInterval:
reverseInterval
,
curve:
curve
,
reverseCurve:
reverseCurve
);
// Updates the value of all the variables in the list according to the given animation clock value and direction
void
setProgress
(
double
t
,
Direction
direction
)
{
double
adjustedTime
=
transform
(
t
,
direction
);
for
(
AnimatedVariable
variable
in
variables
)
variable
.
setProgress
(
adjustedTime
,
direction
);
}
String
toString
()
=>
'AnimatedList([
$variables
])'
;
}
/// An animated variable containing a color
///
/// This class specializes the interpolation of AnimatedValue<Color> to be
...
...
@@ -153,8 +135,8 @@ class AnimatedColorValue extends AnimatedValue<Color> {
///
/// This class specializes the interpolation of AnimatedValue<Rect> to be
/// appropriate for rectangles.
class
AnimatedRect
extends
AnimatedValue
<
Rect
>
{
AnimatedRect
(
Rect
begin
,
{
Rect
end
,
Interval
interval
,
Interval
reverseInterval
,
Curve
curve
,
Curve
reverseCurve
})
class
AnimatedRect
Value
extends
AnimatedValue
<
Rect
>
{
AnimatedRect
Value
(
Rect
begin
,
{
Rect
end
,
Interval
interval
,
Interval
reverseInterval
,
Curve
curve
,
Curve
reverseCurve
})
:
super
(
begin
,
end:
end
,
interval:
interval
,
reverseInterval:
reverseInterval
,
curve:
curve
,
reverseCurve:
reverseCurve
);
Rect
lerp
(
double
t
)
=>
Rect
.
lerp
(
begin
,
end
,
t
);
...
...
packages/flutter/lib/src/animation/
animation_
performance.dart
→
packages/flutter/lib/src/animation/performance.dart
View file @
3f82552d
...
...
@@ -9,7 +9,7 @@ import 'package:sky/src/animation/forces.dart';
import
'package:sky/src/animation/simulation_stepper.dart'
;
/// The status of an animation
enum
Animation
Status
{
enum
Performance
Status
{
/// The animation is stopped at the beginning
dismissed
,
...
...
@@ -23,27 +23,27 @@ enum AnimationStatus {
completed
,
}
typedef
void
Animation
PerformanceListener
(
);
typedef
void
AnimationPerformanceStatusListener
(
Animation
Status
status
);
typedef
void
PerformanceListener
(
);
typedef
void
PerformanceStatusListener
(
Performance
Status
status
);
/// An interface that is implemented by [
Animation
Performance] that exposes a
/// An interface that is implemented by [Performance] that exposes a
/// read-only view of the underlying performance. This is used by classes that
/// want to watch a performance but should not be able to change the
/// performance's state.
abstract
class
WatchableAnimationPerformance
{
abstract
class
PerformanceView
{
/// Update the given variable according to the current progress of the performance
void
updateVariable
(
Animat
edVari
able
variable
);
void
updateVariable
(
Animatable
variable
);
/// Calls the listener every time the progress of the performance changes
void
addListener
(
Animation
PerformanceListener
listener
);
void
addListener
(
PerformanceListener
listener
);
/// Stop calling the listener every time the progress of the performance changes
void
removeListener
(
Animation
PerformanceListener
listener
);
void
removeListener
(
PerformanceListener
listener
);
/// Calls listener every time the status of the performance changes
void
addStatusListener
(
Animation
PerformanceStatusListener
listener
);
void
addStatusListener
(
PerformanceStatusListener
listener
);
/// Stops calling the listener every time the status of the performance changes
void
removeStatusListener
(
Animation
PerformanceStatusListener
listener
);
void
removeStatusListener
(
PerformanceStatusListener
listener
);
}
/// A timeline that can be reversed and used to update [Animat
edVari
able]s.
/// A timeline that can be reversed and used to update [Animatable]s.
///
/// For example, a performance may handle an animation of a menu opening by
/// sliding and fading in (changing Y value and opacity) over .5 seconds. The
...
...
@@ -51,30 +51,30 @@ abstract class WatchableAnimationPerformance {
/// may also take direct control of the timeline by manipulating [progress], or
/// [fling] the timeline causing a physics-based simulation to take over the
/// progression.
class
AnimationPerformance
implements
WatchableAnimationPerformance
{
Animation
Performance
({
this
.
duration
,
double
progress
})
{
class
Performance
implements
PerformanceView
{
Performance
({
this
.
duration
,
double
progress
})
{
_timeline
=
new
SimulationStepper
(
_tick
);
if
(
progress
!=
null
)
_timeline
.
value
=
progress
.
clamp
(
0.0
,
1.0
);
}
/// Returns a [
WatchableAnimationPerformance
] for this performance,
/// Returns a [
PerformanceView
] for this performance,
/// so that a pointer to this object can be passed around without
/// allowing users of that pointer to mutate the AnimationPerformance state.
WatchableAnimationPerformance
get
view
=>
this
;
PerformanceView
get
view
=>
this
;
/// The length of time this performance should last
Duration
duration
;
SimulationStepper
_timeline
;
Direction
_direction
;
Animation
Direction
_direction
;
/// The direction used to select the current curve
///
/// Curve direction is only reset when we hit the beginning or the end of the
/// timeline to avoid discontinuities in the value of any variables this
/// performance is used to animate.
Direction
_curveDirection
;
Animation
Direction
_curveDirection
;
/// If non-null, animate with this timing instead of a linear timing
AnimationTiming
timing
;
...
...
@@ -95,45 +95,45 @@ class AnimationPerformance implements WatchableAnimationPerformance {
}
/// Whether this animation is stopped at the beginning
bool
get
isDismissed
=>
status
==
Animation
Status
.
dismissed
;
bool
get
isDismissed
=>
status
==
Performance
Status
.
dismissed
;
/// Whether this animation is stopped at the end
bool
get
isCompleted
=>
status
==
Animation
Status
.
completed
;
bool
get
isCompleted
=>
status
==
Performance
Status
.
completed
;
/// Whether this animation is currently animating in either the forward or reverse direction
bool
get
isAnimating
=>
_timeline
.
isAnimating
;
/// The current status of this animation
Animation
Status
get
status
{
Performance
Status
get
status
{
if
(!
isAnimating
&&
progress
==
1.0
)
return
Animation
Status
.
completed
;
return
Performance
Status
.
completed
;
if
(!
isAnimating
&&
progress
==
0.0
)
return
Animation
Status
.
dismissed
;
return
_direction
==
Direction
.
forward
?
Animation
Status
.
forward
:
Animation
Status
.
reverse
;
return
Performance
Status
.
dismissed
;
return
_direction
==
Animation
Direction
.
forward
?
Performance
Status
.
forward
:
Performance
Status
.
reverse
;
}
/// Update the given varaible according to the current progress of this performance
void
updateVariable
(
Animat
edVari
able
variable
)
{
void
updateVariable
(
Animatable
variable
)
{
variable
.
setProgress
(
_curvedProgress
,
_curveDirection
);
}
/// Start running this animation forwards (towards the end)
Future
forward
()
=>
play
(
Direction
.
forward
);
Future
forward
()
=>
play
(
Animation
Direction
.
forward
);
/// Start running this animation in reverse (towards the beginning)
Future
reverse
()
=>
play
(
Direction
.
reverse
);
Future
reverse
()
=>
play
(
Animation
Direction
.
reverse
);
/// Start running this animation in the given direction
Future
play
([
Direction
direction
=
Direction
.
forward
])
{
Future
play
([
AnimationDirection
direction
=
Animation
Direction
.
forward
])
{
_direction
=
direction
;
return
resume
();
}
/// Start running this animation in the most recent
ly
direction
/// Start running this animation in the most recent direction
Future
resume
()
{
return
_animateTo
(
_direction
==
Direction
.
forward
?
1.0
:
0.0
);
return
_animateTo
(
_direction
==
Animation
Direction
.
forward
?
1.0
:
0.0
);
}
/// Stop running this animation
...
...
@@ -149,46 +149,46 @@ class AnimationPerformance implements WatchableAnimationPerformance {
Future
fling
({
double
velocity:
1.0
,
Force
force
})
{
if
(
force
==
null
)
force
=
kDefaultSpringForce
;
_direction
=
velocity
<
0.0
?
Direction
.
reverse
:
Direction
.
forward
;
_direction
=
velocity
<
0.0
?
AnimationDirection
.
reverse
:
Animation
Direction
.
forward
;
return
_timeline
.
animateWith
(
force
.
release
(
progress
,
velocity
));
}
final
List
<
AnimationPerformanceListener
>
_listeners
=
new
List
<
Animation
PerformanceListener
>();
final
List
<
PerformanceListener
>
_listeners
=
new
List
<
PerformanceListener
>();
/// Calls the listener every time the progress of this performance changes
void
addListener
(
Animation
PerformanceListener
listener
)
{
void
addListener
(
PerformanceListener
listener
)
{
_listeners
.
add
(
listener
);
}
/// Stop calling the listener every time the progress of this performance changes
void
removeListener
(
Animation
PerformanceListener
listener
)
{
void
removeListener
(
PerformanceListener
listener
)
{
_listeners
.
remove
(
listener
);
}
void
_notifyListeners
()
{
List
<
AnimationPerformanceListener
>
localListeners
=
new
List
<
Animation
PerformanceListener
>.
from
(
_listeners
);
for
(
Animation
PerformanceListener
listener
in
localListeners
)
List
<
PerformanceListener
>
localListeners
=
new
List
<
PerformanceListener
>.
from
(
_listeners
);
for
(
PerformanceListener
listener
in
localListeners
)
listener
();
}
final
List
<
AnimationPerformanceStatusListener
>
_statusListeners
=
new
List
<
Animation
PerformanceStatusListener
>();
final
List
<
PerformanceStatusListener
>
_statusListeners
=
new
List
<
PerformanceStatusListener
>();
/// Calls listener every time the status of this performance changes
void
addStatusListener
(
Animation
PerformanceStatusListener
listener
)
{
void
addStatusListener
(
PerformanceStatusListener
listener
)
{
_statusListeners
.
add
(
listener
);
}
/// Stops calling the listener every time the status of this performance changes
void
removeStatusListener
(
Animation
PerformanceStatusListener
listener
)
{
void
removeStatusListener
(
PerformanceStatusListener
listener
)
{
_statusListeners
.
remove
(
listener
);
}
AnimationStatus
_lastStatus
=
Animation
Status
.
dismissed
;
PerformanceStatus
_lastStatus
=
Performance
Status
.
dismissed
;
void
_checkStatusChanged
()
{
Animation
Status
currentStatus
=
status
;
Performance
Status
currentStatus
=
status
;
if
(
currentStatus
!=
_lastStatus
)
{
List
<
AnimationPerformanceStatusListener
>
localListeners
=
new
List
<
Animation
PerformanceStatusListener
>.
from
(
_statusListeners
);
for
(
Animation
PerformanceStatusListener
listener
in
localListeners
)
List
<
PerformanceStatusListener
>
localListeners
=
new
List
<
PerformanceStatusListener
>.
from
(
_statusListeners
);
for
(
PerformanceStatusListener
listener
in
localListeners
)
listener
(
currentStatus
);
}
_lastStatus
=
currentStatus
;
...
...
@@ -196,7 +196,7 @@ class AnimationPerformance implements WatchableAnimationPerformance {
void
_updateCurveDirection
()
{
if
(
status
!=
_lastStatus
)
{
if
(
_lastStatus
==
AnimationStatus
.
dismissed
||
_lastStatus
==
Animation
Status
.
completed
)
if
(
_lastStatus
==
PerformanceStatus
.
dismissed
||
_lastStatus
==
Performance
Status
.
completed
)
_curveDirection
=
_direction
;
}
}
...
...
@@ -221,8 +221,8 @@ class AnimationPerformance implements WatchableAnimationPerformance {
}
/// An animation performance with an animated variable with a concrete type
class
Value
Animation
<
T
>
extends
Animation
Performance
{
Value
Animation
({
this
.
variable
,
Duration
duration
,
double
progress
})
:
class
Value
Performance
<
T
>
extends
Performance
{
Value
Performance
({
this
.
variable
,
Duration
duration
,
double
progress
})
:
super
(
duration:
duration
,
progress:
progress
);
AnimatedValue
<
T
>
variable
;
...
...
packages/flutter/lib/src/animation/simulation_stepper.dart
View file @
3f82552d
...
...
@@ -28,7 +28,7 @@ class _TweenSimulation extends Simulation {
double
x
(
double
timeInSeconds
)
{
assert
(
timeInSeconds
>=
0.0
);
final
double
t
=
(
timeInSeconds
/
_durationInSeconds
).
clamp
(
0.0
,
1.0
);
_tween
.
setProgress
(
t
,
Direction
.
forward
);
_tween
.
setProgress
(
t
,
Animation
Direction
.
forward
);
return
_tween
.
value
;
}
...
...
packages/flutter/lib/src/painting/radial_reaction.dart
View file @
3f82552d
...
...
@@ -30,13 +30,13 @@ class RadialReaction {
_outerOpacity
=
new
AnimatedValue
<
double
>(
0.0
,
end:
_kMaxOpacity
,
curve:
easeOut
);
_innerCenter
=
new
AnimatedValue
<
Point
>(
startPosition
,
end:
center
,
curve:
easeOut
);
_innerRadius
=
new
AnimatedValue
<
double
>(
0.0
,
end:
radius
,
curve:
easeOut
);
_showPerformance
=
new
Animation
Performance
(
duration:
_kShowDuration
)
_showPerformance
=
new
Performance
(
duration:
_kShowDuration
)
..
addListener
(()
{
_showPerformance
.
updateVariable
(
_outerOpacity
);
_showPerformance
.
updateVariable
(
_innerCenter
);
_showPerformance
.
updateVariable
(
_innerRadius
);
});
_fade
=
new
Value
Animation
<
double
>(
_fade
=
new
Value
Performance
<
double
>(
variable:
new
AnimatedValue
(
1.0
,
end:
0.0
,
curve:
easeIn
),
duration:
_kHideDuration
);
...
...
@@ -48,14 +48,14 @@ class RadialReaction {
/// The radius of the circle in which the reaction occurs
final
double
radius
;
Animation
Performance
_showPerformance
;
Performance
_showPerformance
;
AnimatedValue
<
double
>
_outerOpacity
;
AnimatedValue
<
Point
>
_innerCenter
;
AnimatedValue
<
double
>
_innerRadius
;
Future
_showComplete
;
Value
Animation
<
double
>
_fade
;
Value
Performance
<
double
>
_fade
;
/// Show the reaction
///
...
...
packages/flutter/lib/src/rendering/toggleable.dart
View file @
3f82552d
...
...
@@ -24,15 +24,15 @@ abstract class RenderToggleable extends RenderConstrainedBox {
:
_value
=
value
,
_onChanged
=
onChanged
,
super
(
additionalConstraints:
new
BoxConstraints
.
tight
(
size
))
{
_performance
=
new
Value
Animation
<
double
>(
_performance
=
new
Value
Performance
<
double
>(
variable:
new
AnimatedValue
<
double
>(
0.0
,
end:
1.0
,
curve:
easeIn
,
reverseCurve:
easeOut
),
duration:
_kToggleDuration
,
progress:
_value
?
1.0
:
0.0
)..
addListener
(
markNeedsPaint
);
}
Value
Animation
<
double
>
get
performance
=>
_performance
;
Value
Animation
<
double
>
_performance
;
Value
Performance
<
double
>
get
performance
=>
_performance
;
Value
Performance
<
double
>
_performance
;
double
get
position
=>
_performance
.
value
;
...
...
@@ -68,7 +68,7 @@ abstract class RenderToggleable extends RenderConstrainedBox {
if
(
value
==
_value
)
return
;
_value
=
value
;
performance
.
play
(
value
?
Direction
.
forward
:
Direction
.
reverse
);
performance
.
play
(
value
?
AnimationDirection
.
forward
:
Animation
Direction
.
reverse
);
}
ValueChanged
get
onChanged
=>
_onChanged
;
...
...
packages/flutter/lib/src/widgets/animated_component.dart
View file @
3f82552d
...
...
@@ -9,13 +9,13 @@ abstract class AnimatedComponent extends StatefulComponent {
const
AnimatedComponent
({
Key
key
,
this
.
direction
,
this
.
duration
})
:
super
(
key:
key
);
final
Duration
duration
;
final
Direction
direction
;
final
Animation
Direction
direction
;
}
abstract
class
AnimatedState
<
T
extends
AnimatedComponent
>
extends
State
<
T
>
{
void
initState
()
{
super
.
initState
();
_performance
=
new
Animation
Performance
(
duration:
config
.
duration
);
_performance
=
new
Performance
(
duration:
config
.
duration
);
performance
.
addStatusListener
(
_handleAnimationStatusChanged
);
if
(
buildDependsOnPerformance
)
{
performance
.
addListener
(()
{
...
...
@@ -34,13 +34,13 @@ abstract class AnimatedState<T extends AnimatedComponent> extends State<T> {
performance
.
play
(
config
.
direction
);
}
Animation
Performance
get
performance
=>
_performance
;
Animation
Performance
_performance
;
Performance
get
performance
=>
_performance
;
Performance
_performance
;
void
_handleAnimationStatusChanged
(
Animation
Status
status
)
{
if
(
status
==
Animation
Status
.
completed
)
void
_handleAnimationStatusChanged
(
Performance
Status
status
)
{
if
(
status
==
Performance
Status
.
completed
)
handleCompleted
();
else
if
(
status
==
Animation
Status
.
dismissed
)
else
if
(
status
==
Performance
Status
.
dismissed
)
handleDismissed
();
}
...
...
packages/flutter/lib/src/widgets/animated_container.dart
View file @
3f82552d
...
...
@@ -90,11 +90,11 @@ class AnimatedContainerState extends State<AnimatedContainer> {
AnimatedValue
<
double
>
_width
;
AnimatedValue
<
double
>
_height
;
Animation
Performance
_performance
;
Performance
_performance
;
void
initState
()
{
super
.
initState
();
_performance
=
new
Animation
Performance
(
duration:
config
.
duration
)
_performance
=
new
Performance
(
duration:
config
.
duration
)
..
timing
=
new
AnimationTiming
(
curve:
config
.
curve
)
..
addListener
(
_updateAllVariables
);
_configAllVariables
();
...
...
@@ -115,7 +115,7 @@ class AnimatedContainerState extends State<AnimatedContainer> {
super
.
dispose
();
}
void
_updateVariable
(
Animat
edVari
able
variable
)
{
void
_updateVariable
(
Animatable
variable
)
{
if
(
variable
!=
null
)
_performance
.
updateVariable
(
variable
);
}
...
...
packages/flutter/lib/src/widgets/dialog.dart
View file @
3f82552d
...
...
@@ -141,7 +141,7 @@ class DialogRoute extends Route {
Duration
get
transitionDuration
=>
_kTransitionDuration
;
bool
get
opaque
=>
false
;
Widget
build
(
NavigatorState
navigator
,
WatchableAnimationPerformance
nextRoutePerformance
)
{
Widget
build
(
NavigatorState
navigator
,
PerformanceView
nextRoutePerformance
)
{
return
new
FadeTransition
(
performance:
performance
,
opacity:
new
AnimatedValue
<
double
>(
0.0
,
end:
1.0
,
curve:
easeOut
),
...
...
packages/flutter/lib/src/widgets/dismissable.dart
View file @
3f82552d
...
...
@@ -50,15 +50,15 @@ class Dismissable extends StatefulComponent {
class
DismissableState
extends
State
<
Dismissable
>
{
void
initState
()
{
super
.
initState
();
_fadePerformance
=
new
Animation
Performance
(
duration:
_kCardDismissFadeout
);
_fadePerformance
.
addStatusListener
((
Animation
Status
status
)
{
if
(
status
==
Animation
Status
.
completed
)
_fadePerformance
=
new
Performance
(
duration:
_kCardDismissFadeout
);
_fadePerformance
.
addStatusListener
((
Performance
Status
status
)
{
if
(
status
==
Performance
Status
.
completed
)
_handleFadeCompleted
();
});
}
Animation
Performance
_fadePerformance
;
Animation
Performance
_resizePerformance
;
Performance
_fadePerformance
;
Performance
_resizePerformance
;
Size
_size
;
double
_dragExtent
=
0.0
;
...
...
@@ -97,7 +97,7 @@ class DismissableState extends State<Dismissable> {
assert
(
_resizePerformance
==
null
);
setState
(()
{
_resizePerformance
=
new
Animation
Performance
()
_resizePerformance
=
new
Performance
()
..
duration
=
_kCardDismissResize
..
addListener
(
_handleResizeProgressChanged
);
_resizePerformance
.
play
();
...
...
@@ -221,7 +221,7 @@ class DismissableState extends State<Dismissable> {
Widget
build
(
BuildContext
context
)
{
if
(
_resizePerformance
!=
null
)
{
// make sure you remove this widget once it's been dismissed!
assert
(
_resizePerformance
.
status
==
Animation
Status
.
forward
);
assert
(
_resizePerformance
.
status
==
Performance
Status
.
forward
);
AnimatedValue
<
double
>
squashAxisExtent
=
new
AnimatedValue
<
double
>(
_directionIsYAxis
?
_size
.
width
:
_size
.
height
,
...
...
packages/flutter/lib/src/widgets/drag_target.dart
View file @
3f82552d
...
...
@@ -258,7 +258,7 @@ class DragRoute extends Route {
bool
get
opaque
=>
false
;
Duration
get
transitionDuration
=>
const
Duration
();
Widget
build
(
NavigatorState
navigator
,
WatchableAnimationPerformance
nextRoutePerformance
)
{
Widget
build
(
NavigatorState
navigator
,
PerformanceView
nextRoutePerformance
)
{
return
new
Positioned
(
left:
_lastOffset
.
dx
,
top:
_lastOffset
.
dy
,
...
...
packages/flutter/lib/src/widgets/drawer.dart
View file @
3f82552d
...
...
@@ -55,15 +55,15 @@ class Drawer extends StatefulComponent {
class
DrawerState
extends
State
<
Drawer
>
{
void
initState
()
{
super
.
initState
();
_performance
=
new
Animation
Performance
(
duration:
_kBaseSettleDuration
)
..
addStatusListener
((
Animation
Status
status
)
{
if
(
status
==
Animation
Status
.
dismissed
)
_performance
=
new
Performance
(
duration:
_kBaseSettleDuration
)
..
addStatusListener
((
Performance
Status
status
)
{
if
(
status
==
Performance
Status
.
dismissed
)
config
.
navigator
.
pop
();
});
_open
();
}
Animation
Performance
_performance
;
Performance
_performance
;
Widget
build
(
BuildContext
context
)
{
Widget
mask
=
new
GestureDetector
(
...
...
@@ -138,7 +138,7 @@ class DrawerRoute extends Route {
bool
get
opaque
=>
false
;
Widget
build
(
NavigatorState
navigator
,
WatchableAnimationPerformance
nextRoutePerformance
)
{
Widget
build
(
NavigatorState
navigator
,
PerformanceView
nextRoutePerformance
)
{
return
new
Focus
(
key:
new
GlobalObjectKey
(
this
),
autofocus:
true
,
...
...
packages/flutter/lib/src/widgets/ink_well.dart
View file @
3f82552d
...
...
@@ -32,7 +32,7 @@ class InkSplash {
_radius
=
new
AnimatedValue
<
double
>(
_kSplashInitialSize
,
end:
_targetRadius
,
curve:
easeOut
);
_performance
=
new
Value
Animation
<
double
>(
_performance
=
new
Value
Performance
<
double
>(
variable:
_radius
,
duration:
new
Duration
(
milliseconds:
(
_targetRadius
/
_kSplashUnconfirmedVelocity
).
floor
())
)..
addListener
(
_handleRadiusChange
);
...
...
@@ -47,7 +47,7 @@ class InkSplash {
double
_targetRadius
;
double
_pinnedRadius
;
AnimatedValue
<
double
>
_radius
;
Animation
Performance
_performance
;
Performance
_performance
;
Timer
_startTimer
;
bool
_cancelStartTimer
()
{
...
...
packages/flutter/lib/src/widgets/navigator.dart
View file @
3f82552d
...
...
@@ -118,7 +118,7 @@ class NavigatorState extends State<Navigator> {
Widget
build
(
BuildContext
context
)
{
List
<
Widget
>
visibleRoutes
=
new
List
<
Widget
>();
bool
alreadyInsertModalBarrier
=
false
;
WatchableAnimationPerformance
nextPerformance
;
PerformanceView
nextPerformance
;
for
(
int
i
=
_history
.
length
-
1
;
i
>=
0
;
i
-=
1
)
{
Route
route
=
_history
[
i
];
if
(!
route
.
hasContent
)
{
...
...
@@ -126,7 +126,7 @@ class NavigatorState extends State<Navigator> {
continue
;
}
route
.
ensurePerformance
(
direction:
(
i
<=
_currentPosition
)
?
Direction
.
forward
:
Direction
.
reverse
direction:
(
i
<=
_currentPosition
)
?
AnimationDirection
.
forward
:
Animation
Direction
.
reverse
);
route
.
_onDismissed
=
()
{
setState
(()
{
...
...
@@ -159,28 +159,28 @@ class NavigatorState extends State<Navigator> {
abstract
class
Route
{
WatchableAnimationPerformance
get
performance
=>
_performance
?.
view
;
Animation
Performance
_performance
;
PerformanceView
get
performance
=>
_performance
?.
view
;
Performance
_performance
;
NotificationCallback
_onDismissed
;
Animation
Performance
createPerformance
()
{
Performance
createPerformance
()
{
Duration
duration
=
transitionDuration
;
if
(
duration
>
Duration
.
ZERO
)
{
return
new
Animation
Performance
(
duration:
duration
)
..
addStatusListener
((
Animation
Status
status
)
{
if
(
status
==
Animation
Status
.
dismissed
&&
_onDismissed
!=
null
)
return
new
Performance
(
duration:
duration
)
..
addStatusListener
((
Performance
Status
status
)
{
if
(
status
==
Performance
Status
.
dismissed
&&
_onDismissed
!=
null
)
_onDismissed
();
});
}
return
null
;
}
void
ensurePerformance
({
Direction
direction
})
{
void
ensurePerformance
({
Animation
Direction
direction
})
{
assert
(
direction
!=
null
);
if
(
_performance
==
null
)
_performance
=
createPerformance
();
if
(
_performance
!=
null
)
{
AnimationStatus
desiredStatus
=
direction
==
Direction
.
forward
?
AnimationStatus
.
forward
:
Animation
Status
.
reverse
;
PerformanceStatus
desiredStatus
=
direction
==
AnimationDirection
.
forward
?
PerformanceStatus
.
forward
:
Performance
Status
.
reverse
;
if
(
_performance
.
status
!=
desiredStatus
)
_performance
.
play
(
direction
);
}
...
...
@@ -236,14 +236,14 @@ abstract class Route {
/// cover the entire application surface or are in any way semi-transparent.
bool
get
opaque
=>
false
;
/// If this is set to a non-zero [Duration], then an [
Animation
Performance]
/// If this is set to a non-zero [Duration], then an [Performance]
/// object, available via the performance field, will be created when the
/// route is first built, using the duration described here.
Duration
get
transitionDuration
=>
Duration
.
ZERO
;
bool
get
isActuallyOpaque
=>
(
performance
==
null
||
_performance
.
isCompleted
)
&&
opaque
;
Widget
build
(
NavigatorState
navigator
,
WatchableAnimationPerformance
nextRoutePerformance
);
Widget
build
(
NavigatorState
navigator
,
PerformanceView
nextRoutePerformance
);
void
didPop
([
dynamic
result
])
{
if
(
performance
==
null
&&
_onDismissed
!=
null
)
_onDismissed
();
...
...
@@ -263,7 +263,7 @@ class PageRoute extends Route {
bool
get
opaque
=>
true
;
Duration
get
transitionDuration
=>
_kTransitionDuration
;
Widget
build
(
NavigatorState
navigator
,
WatchableAnimationPerformance
nextRoutePerformance
)
{
Widget
build
(
NavigatorState
navigator
,
PerformanceView
nextRoutePerformance
)
{
// TODO(jackson): Hit testing should ignore transform
// TODO(jackson): Block input unless content is interactive
return
new
SlideTransition
(
...
...
@@ -296,5 +296,5 @@ class StateRoute extends Route {
super
.
didPop
(
result
);
}
Widget
build
(
NavigatorState
navigator
,
WatchableAnimationPerformance
nextRoutePerformance
)
=>
null
;
Widget
build
(
NavigatorState
navigator
,
PerformanceView
nextRoutePerformance
)
=>
null
;
}
packages/flutter/lib/src/widgets/popup_menu.dart
View file @
3f82552d
...
...
@@ -44,7 +44,7 @@ class PopupMenu extends StatefulComponent {
final
List
<
PopupMenuItem
>
items
;
final
int
level
;
final
NavigatorState
navigator
;
final
WatchableAnimationPerformance
performance
;
final
PerformanceView
performance
;
PopupMenuState
createState
()
=>
new
PopupMenuState
();
}
...
...
@@ -159,8 +159,8 @@ class MenuRoute extends Route {
final
PopupMenuItemsBuilder
builder
;
final
int
level
;
Animation
Performance
createPerformance
()
{
Animation
Performance
result
=
super
.
createPerformance
();
Performance
createPerformance
()
{
Performance
result
=
super
.
createPerformance
();
AnimationTiming
timing
=
new
AnimationTiming
();
timing
.
reverseInterval
=
new
Interval
(
0.0
,
_kMenuCloseIntervalEnd
);
result
.
timing
=
timing
;
...
...
@@ -172,7 +172,7 @@ class MenuRoute extends Route {
bool
get
opaque
=>
false
;
Duration
get
transitionDuration
=>
_kMenuDuration
;
Widget
build
(
NavigatorState
navigator
,
WatchableAnimationPerformance
nextRoutePerformance
)
{
Widget
build
(
NavigatorState
navigator
,
PerformanceView
nextRoutePerformance
)
{
return
new
Positioned
(
top:
position
?.
top
,
right:
position
?.
right
,
...
...
packages/flutter/lib/src/widgets/progress_indicator.dart
View file @
3f82552d
...
...
@@ -36,16 +36,16 @@ abstract class ProgressIndicator extends StatefulComponent {
class
ProgressIndicatorState
extends
State
<
ProgressIndicator
>
{
Value
Animation
<
double
>
_performance
;
Value
Performance
<
double
>
_performance
;
void
initState
()
{
super
.
initState
();
_performance
=
new
Value
Animation
<
double
>(
_performance
=
new
Value
Performance
<
double
>(
variable:
new
AnimatedValue
<
double
>(
0.0
,
end:
1.0
,
curve:
ease
),
duration:
const
Duration
(
milliseconds:
1500
)
);
_performance
.
addStatusListener
((
Animation
Status
status
)
{
if
(
status
==
Animation
Status
.
completed
)
_performance
.
addStatusListener
((
Performance
Status
status
)
{
if
(
status
==
Performance
Status
.
completed
)
_restartAnimation
();
});
_performance
.
play
();
...
...
packages/flutter/lib/src/widgets/snack_bar.dart
View file @
3f82552d
...
...
@@ -49,7 +49,7 @@ class SnackBar extends AnimatedComponent {
this
.
actions
,
bool
showing
,
this
.
onDismissed
})
:
super
(
key:
key
,
direction:
showing
?
Direction
.
forward
:
Direction
.
reverse
,
duration:
_kSlideInDuration
)
{
})
:
super
(
key:
key
,
direction:
showing
?
AnimationDirection
.
forward
:
Animation
Direction
.
reverse
,
duration:
_kSlideInDuration
)
{
assert
(
content
!=
null
);
}
...
...
packages/flutter/lib/src/widgets/tabs.dart
View file @
3f82552d
...
...
@@ -408,16 +408,16 @@ class TabBar extends Scrollable {
class
TabBarState
extends
ScrollableState
<
TabBar
>
{
void
initState
()
{
super
.
initState
();
_indicatorAnimation
=
new
Value
Animation
<
Rect
>()
_indicatorAnimation
=
new
Value
Performance
<
Rect
>()
..
duration
=
_kTabBarScroll
..
variable
=
new
AnimatedRect
(
null
,
curve:
ease
);
..
variable
=
new
AnimatedRect
Value
(
null
,
curve:
ease
);
scrollBehavior
.
isScrollable
=
config
.
isScrollable
;
}
Size
_tabBarSize
;
Size
_viewportSize
=
Size
.
zero
;
List
<
double
>
_tabWidths
;
Value
Animation
<
Rect
>
_indicatorAnimation
;
Value
Performance
<
Rect
>
_indicatorAnimation
;
void
didUpdateConfig
(
TabBar
oldConfig
)
{
super
.
didUpdateConfig
(
oldConfig
);
...
...
@@ -425,7 +425,7 @@ class TabBarState extends ScrollableState<TabBar> {
scrollTo
(
0.0
);
}
AnimatedRect
get
_indicatorRect
=>
_indicatorAnimation
.
variable
;
AnimatedRect
Value
get
_indicatorRect
=>
_indicatorAnimation
.
variable
;
void
_startIndicatorAnimation
(
int
fromTabIndex
,
int
toTabIndex
)
{
_indicatorRect
...
...
packages/flutter/lib/src/widgets/transitions.dart
View file @
3f82552d
...
...
@@ -7,7 +7,7 @@ import 'package:sky/src/widgets/basic.dart';
import
'package:sky/src/widgets/framework.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
export
'package:sky/animation.dart'
show
Direction
;
export
'package:sky/animation.dart'
show
Animation
Direction
;
abstract
class
TransitionComponent
extends
StatefulComponent
{
TransitionComponent
({
...
...
@@ -17,7 +17,7 @@ abstract class TransitionComponent extends StatefulComponent {
assert
(
performance
!=
null
);
}
final
WatchableAnimationPerformance
performance
;
final
PerformanceView
performance
;
Widget
build
(
BuildContext
context
);
...
...
@@ -57,7 +57,7 @@ abstract class TransitionWithChild extends TransitionComponent {
TransitionWithChild
({
Key
key
,
this
.
child
,
WatchableAnimationPerformance
performance
PerformanceView
performance
})
:
super
(
key:
key
,
performance:
performance
);
final
Widget
child
;
...
...
@@ -71,7 +71,7 @@ class SlideTransition extends TransitionWithChild {
SlideTransition
({
Key
key
,
this
.
position
,
WatchableAnimationPerformance
performance
,
PerformanceView
performance
,
Widget
child
})
:
super
(
key:
key
,
performance:
performance
,
...
...
@@ -91,7 +91,7 @@ class FadeTransition extends TransitionWithChild {
FadeTransition
({
Key
key
,
this
.
opacity
,
WatchableAnimationPerformance
performance
,
PerformanceView
performance
,
Widget
child
})
:
super
(
key:
key
,
performance:
performance
,
...
...
@@ -109,7 +109,7 @@ class ColorTransition extends TransitionWithChild {
ColorTransition
({
Key
key
,
this
.
color
,
WatchableAnimationPerformance
performance
,
PerformanceView
performance
,
Widget
child
})
:
super
(
key:
key
,
performance:
performance
,
...
...
@@ -131,7 +131,7 @@ class SquashTransition extends TransitionWithChild {
Key
key
,
this
.
width
,
this
.
height
,
WatchableAnimationPerformance
performance
,
PerformanceView
performance
,
Widget
child
})
:
super
(
key:
key
,
performance:
performance
,
...
...
@@ -156,7 +156,7 @@ class BuilderTransition extends TransitionComponent {
Key
key
,
this
.
variables
,
this
.
builder
,
WatchableAnimationPerformance
performance
PerformanceView
performance
})
:
super
(
key:
key
,
performance:
performance
);
...
...
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