diff --git a/examples/fitness/lib/feed.dart b/examples/fitness/lib/feed.dart index 221b7056f8..b7555f92e6 100644 --- a/examples/fitness/lib/feed.dart +++ b/examples/fitness/lib/feed.dart @@ -60,7 +60,7 @@ class FeedFragment extends StatefulComponent { class FeedFragmentState extends State { FitnessMode _fitnessMode = FitnessMode.feed; - AnimationStatus _snackBarStatus = AnimationStatus.dismissed; + PerformanceStatus _snackBarStatus = PerformanceStatus.dismissed; bool _isShowingSnackBar = false; void _handleFitnessModeChange(FitnessMode value) { @@ -126,7 +126,7 @@ class FeedFragmentState extends State { setState(() { _undoItem = item; _isShowingSnackBar = true; - _snackBarStatus = AnimationStatus.forward; + _snackBarStatus = PerformanceStatus.forward; }); } @@ -207,13 +207,13 @@ class FeedFragmentState extends State { } Widget buildSnackBar() { - if (_snackBarStatus == AnimationStatus.dismissed) + if (_snackBarStatus == PerformanceStatus.dismissed) return null; return new SnackBar( showing: _isShowingSnackBar, content: new Text("Item deleted."), actions: [new SnackBarAction(label: "UNDO", onPressed: _handleUndo)], - onDismissed: () { setState(() { _snackBarStatus = AnimationStatus.dismissed; }); } + onDismissed: () { setState(() { _snackBarStatus = PerformanceStatus.dismissed; }); } ); } diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index 80e399ce8b..091e379f67 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -25,7 +25,7 @@ class StockHomeState extends State { bool _isSearching = false; String _searchQuery; - AnimationStatus _snackBarStatus = AnimationStatus.dismissed; + PerformanceStatus _snackBarStatus = PerformanceStatus.dismissed; bool _isSnackBarShowing = false; void _handleSearchBegin() { @@ -224,20 +224,20 @@ class StockHomeState extends State { GlobalKey snackBarKey = new GlobalKey(label: 'snackbar'); Widget buildSnackBar() { - if (_snackBarStatus == AnimationStatus.dismissed) + if (_snackBarStatus == PerformanceStatus.dismissed) return null; return new SnackBar( showing: _isSnackBarShowing, content: new Text("Stock purchased!"), actions: [new SnackBarAction(label: "UNDO", onPressed: _handleUndo)], - onDismissed: () { setState(() { _snackBarStatus = AnimationStatus.dismissed; }); } + onDismissed: () { setState(() { _snackBarStatus = PerformanceStatus.dismissed; }); } ); } void _handleStockPurchased() { setState(() { _isSnackBarShowing = true; - _snackBarStatus = AnimationStatus.forward; + _snackBarStatus = PerformanceStatus.forward; }); } diff --git a/examples/widgets/progress_indicator.dart b/examples/widgets/progress_indicator.dart index 1024d37138..e769784b46 100644 --- a/examples/widgets/progress_indicator.dart +++ b/examples/widgets/progress_indicator.dart @@ -13,7 +13,7 @@ class ProgressIndicatorApp extends StatefulComponent { class ProgressIndicatorAppState extends State { void initState() { super.initState(); - valueAnimation = new ValueAnimation() + valueAnimation = new ValuePerformance() ..duration = const Duration(milliseconds: 1500) ..variable = new AnimatedValue( 0.0, @@ -22,15 +22,15 @@ class ProgressIndicatorAppState extends State { reverseCurve: ease, interval: new Interval(0.0, 0.9) ); - valueAnimation.addStatusListener((AnimationStatus status) { - if (status == AnimationStatus.dismissed || status == AnimationStatus.completed) + valueAnimation.addStatusListener((PerformanceStatus status) { + if (status == PerformanceStatus.dismissed || status == PerformanceStatus.completed) reverseValueAnimationDirection(); }); valueAnimation.play(valueAnimationDirection); } - ValueAnimation valueAnimation; - Direction valueAnimationDirection = Direction.forward; + ValuePerformance valueAnimation; + AnimationDirection valueAnimationDirection = AnimationDirection.forward; void handleTap() { setState(() { @@ -43,9 +43,9 @@ class ProgressIndicatorAppState extends State { } void reverseValueAnimationDirection() { - valueAnimationDirection = (valueAnimationDirection == Direction.forward) - ? Direction.reverse - : Direction.forward; + valueAnimationDirection = (valueAnimationDirection == AnimationDirection.forward) + ? AnimationDirection.reverse + : AnimationDirection.forward; valueAnimation.play(valueAnimationDirection); } diff --git a/packages/flutter/lib/animation.dart b/packages/flutter/lib/animation.dart index 564f8cdae4..e9c75373b7 100644 --- a/packages/flutter/lib/animation.dart +++ b/packages/flutter/lib/animation.dart @@ -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'; diff --git a/packages/flutter/lib/src/animation/animated_value.dart b/packages/flutter/lib/src/animation/animated_value.dart index 732c8f2855..f42c4b8910 100644 --- a/packages/flutter/lib/src/animation/animated_value.dart +++ b/packages/flutter/lib/src/animation/animated_value.dart @@ -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 AnimationDirection { /// 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. /// -/// AnimatedVariables, by convention, must be cheap to create. This allows them to be used in -/// build functions in Widgets. -abstract class AnimatedVariable { +/// Animatable 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, AnimationDirection 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, AnimationDirection 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(AnimationDirection direction) { + if (direction == AnimationDirection.forward || reverseInterval == null) return interval; return reverseInterval; } - Curve _getCurve(Direction direction) { - if (direction == Direction.forward || reverseCurve == null) + Curve _getCurve(AnimationDirection direction) { + if (direction == AnimationDirection.forward || reverseCurve == null) return curve; return reverseCurve; } - double _applyCurve(double t, Direction direction) { + double _applyCurve(double t, AnimationDirection 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 extends AnimationTiming implements AnimatedVariable { +class AnimatedValue 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 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, AnimationDirection direction) { if (end != null) { t = transform(t, direction); if (t == 0.0) @@ -120,24 +120,6 @@ class AnimatedValue 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 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 to be @@ -153,8 +135,8 @@ class AnimatedColorValue extends AnimatedValue { /// /// This class specializes the interpolation of AnimatedValue to be /// appropriate for rectangles. -class AnimatedRect extends AnimatedValue { - AnimatedRect(Rect begin, { Rect end, Interval interval, Interval reverseInterval, Curve curve, Curve reverseCurve }) +class AnimatedRectValue extends AnimatedValue { + AnimatedRectValue(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); diff --git a/packages/flutter/lib/src/animation/animation_performance.dart b/packages/flutter/lib/src/animation/performance.dart similarity index 66% rename from packages/flutter/lib/src/animation/animation_performance.dart rename to packages/flutter/lib/src/animation/performance.dart index e9690daf2b..92c77f8b59 100644 --- a/packages/flutter/lib/src/animation/animation_performance.dart +++ b/packages/flutter/lib/src/animation/performance.dart @@ -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 AnimationStatus { +enum PerformanceStatus { /// The animation is stopped at the beginning dismissed, @@ -23,27 +23,27 @@ enum AnimationStatus { completed, } -typedef void AnimationPerformanceListener(); -typedef void AnimationPerformanceStatusListener(AnimationStatus status); +typedef void PerformanceListener(); +typedef void PerformanceStatusListener(PerformanceStatus status); -/// An interface that is implemented by [AnimationPerformance] 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(AnimatedVariable variable); + void updateVariable(Animatable variable); /// Calls the listener every time the progress of the performance changes - void addListener(AnimationPerformanceListener listener); + void addListener(PerformanceListener listener); /// Stop calling the listener every time the progress of the performance changes - void removeListener(AnimationPerformanceListener listener); + void removeListener(PerformanceListener listener); /// Calls listener every time the status of the performance changes - void addStatusListener(AnimationPerformanceStatusListener listener); + void addStatusListener(PerformanceStatusListener listener); /// Stops calling the listener every time the status of the performance changes - void removeStatusListener(AnimationPerformanceStatusListener listener); + void removeStatusListener(PerformanceStatusListener listener); } -/// A timeline that can be reversed and used to update [AnimatedVariable]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 { - AnimationPerformance({ 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; + AnimationDirection _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; + AnimationDirection _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 == AnimationStatus.dismissed; + bool get isDismissed => status == PerformanceStatus.dismissed; /// Whether this animation is stopped at the end - bool get isCompleted => status == AnimationStatus.completed; + bool get isCompleted => status == PerformanceStatus.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 - AnimationStatus get status { + PerformanceStatus get status { if (!isAnimating && progress == 1.0) - return AnimationStatus.completed; + return PerformanceStatus.completed; if (!isAnimating && progress == 0.0) - return AnimationStatus.dismissed; - return _direction == Direction.forward ? - AnimationStatus.forward : - AnimationStatus.reverse; + return PerformanceStatus.dismissed; + return _direction == AnimationDirection.forward ? + PerformanceStatus.forward : + PerformanceStatus.reverse; } /// Update the given varaible according to the current progress of this performance - void updateVariable(AnimatedVariable 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(AnimationDirection.forward); /// Start running this animation in reverse (towards the beginning) - Future reverse() => play(Direction.reverse); + Future reverse() => play(AnimationDirection.reverse); /// Start running this animation in the given direction - Future play([Direction direction = Direction.forward]) { + Future play([AnimationDirection direction = AnimationDirection.forward]) { _direction = direction; return resume(); } - /// Start running this animation in the most recently direction + /// Start running this animation in the most recent direction Future resume() { - return _animateTo(_direction == Direction.forward ? 1.0 : 0.0); + return _animateTo(_direction == AnimationDirection.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 : AnimationDirection.forward; return _timeline.animateWith(force.release(progress, velocity)); } - final List _listeners = new List(); + final List _listeners = new List(); /// Calls the listener every time the progress of this performance changes - void addListener(AnimationPerformanceListener listener) { + void addListener(PerformanceListener listener) { _listeners.add(listener); } /// Stop calling the listener every time the progress of this performance changes - void removeListener(AnimationPerformanceListener listener) { + void removeListener(PerformanceListener listener) { _listeners.remove(listener); } void _notifyListeners() { - List localListeners = new List.from(_listeners); - for (AnimationPerformanceListener listener in localListeners) + List localListeners = new List.from(_listeners); + for (PerformanceListener listener in localListeners) listener(); } - final List _statusListeners = new List(); + final List _statusListeners = new List(); /// Calls listener every time the status of this performance changes - void addStatusListener(AnimationPerformanceStatusListener listener) { + void addStatusListener(PerformanceStatusListener listener) { _statusListeners.add(listener); } /// Stops calling the listener every time the status of this performance changes - void removeStatusListener(AnimationPerformanceStatusListener listener) { + void removeStatusListener(PerformanceStatusListener listener) { _statusListeners.remove(listener); } - AnimationStatus _lastStatus = AnimationStatus.dismissed; + PerformanceStatus _lastStatus = PerformanceStatus.dismissed; void _checkStatusChanged() { - AnimationStatus currentStatus = status; + PerformanceStatus currentStatus = status; if (currentStatus != _lastStatus) { - List localListeners = new List.from(_statusListeners); - for (AnimationPerformanceStatusListener listener in localListeners) + List localListeners = new List.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 == AnimationStatus.completed) + if (_lastStatus == PerformanceStatus.dismissed || _lastStatus == PerformanceStatus.completed) _curveDirection = _direction; } } @@ -221,8 +221,8 @@ class AnimationPerformance implements WatchableAnimationPerformance { } /// An animation performance with an animated variable with a concrete type -class ValueAnimation extends AnimationPerformance { - ValueAnimation({ this.variable, Duration duration, double progress }) : +class ValuePerformance extends Performance { + ValuePerformance({ this.variable, Duration duration, double progress }) : super(duration: duration, progress: progress); AnimatedValue variable; diff --git a/packages/flutter/lib/src/animation/simulation_stepper.dart b/packages/flutter/lib/src/animation/simulation_stepper.dart index 39ff00c4e8..dee9cb0c73 100644 --- a/packages/flutter/lib/src/animation/simulation_stepper.dart +++ b/packages/flutter/lib/src/animation/simulation_stepper.dart @@ -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, AnimationDirection.forward); return _tween.value; } diff --git a/packages/flutter/lib/src/painting/radial_reaction.dart b/packages/flutter/lib/src/painting/radial_reaction.dart index c7997e4e5e..c2822cb9da 100644 --- a/packages/flutter/lib/src/painting/radial_reaction.dart +++ b/packages/flutter/lib/src/painting/radial_reaction.dart @@ -30,13 +30,13 @@ class RadialReaction { _outerOpacity = new AnimatedValue(0.0, end: _kMaxOpacity, curve: easeOut); _innerCenter = new AnimatedValue(startPosition, end: center, curve: easeOut); _innerRadius = new AnimatedValue(0.0, end: radius, curve: easeOut); - _showPerformance = new AnimationPerformance(duration: _kShowDuration) + _showPerformance = new Performance(duration: _kShowDuration) ..addListener(() { _showPerformance.updateVariable(_outerOpacity); _showPerformance.updateVariable(_innerCenter); _showPerformance.updateVariable(_innerRadius); }); - _fade = new ValueAnimation( + _fade = new ValuePerformance( 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; - AnimationPerformance _showPerformance; + Performance _showPerformance; AnimatedValue _outerOpacity; AnimatedValue _innerCenter; AnimatedValue _innerRadius; Future _showComplete; - ValueAnimation _fade; + ValuePerformance _fade; /// Show the reaction /// diff --git a/packages/flutter/lib/src/rendering/toggleable.dart b/packages/flutter/lib/src/rendering/toggleable.dart index 1a2bbae9ed..bd98d27cdb 100644 --- a/packages/flutter/lib/src/rendering/toggleable.dart +++ b/packages/flutter/lib/src/rendering/toggleable.dart @@ -24,15 +24,15 @@ abstract class RenderToggleable extends RenderConstrainedBox { : _value = value, _onChanged = onChanged, super(additionalConstraints: new BoxConstraints.tight(size)) { - _performance = new ValueAnimation( + _performance = new ValuePerformance( variable: new AnimatedValue(0.0, end: 1.0, curve: easeIn, reverseCurve: easeOut), duration: _kToggleDuration, progress: _value ? 1.0 : 0.0 )..addListener(markNeedsPaint); } - ValueAnimation get performance => _performance; - ValueAnimation _performance; + ValuePerformance get performance => _performance; + ValuePerformance _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 : AnimationDirection.reverse); } ValueChanged get onChanged => _onChanged; diff --git a/packages/flutter/lib/src/widgets/animated_component.dart b/packages/flutter/lib/src/widgets/animated_component.dart index d9b27490c9..cf6acbc34f 100644 --- a/packages/flutter/lib/src/widgets/animated_component.dart +++ b/packages/flutter/lib/src/widgets/animated_component.dart @@ -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 AnimationDirection direction; } abstract class AnimatedState extends State { void initState() { super.initState(); - _performance = new AnimationPerformance(duration: config.duration); + _performance = new Performance(duration: config.duration); performance.addStatusListener(_handleAnimationStatusChanged); if (buildDependsOnPerformance) { performance.addListener(() { @@ -34,13 +34,13 @@ abstract class AnimatedState extends State { performance.play(config.direction); } - AnimationPerformance get performance => _performance; - AnimationPerformance _performance; + Performance get performance => _performance; + Performance _performance; - void _handleAnimationStatusChanged(AnimationStatus status) { - if (status == AnimationStatus.completed) + void _handleAnimationStatusChanged(PerformanceStatus status) { + if (status == PerformanceStatus.completed) handleCompleted(); - else if (status == AnimationStatus.dismissed) + else if (status == PerformanceStatus.dismissed) handleDismissed(); } diff --git a/packages/flutter/lib/src/widgets/animated_container.dart b/packages/flutter/lib/src/widgets/animated_container.dart index 291023e9f2..4d1f1d4de0 100644 --- a/packages/flutter/lib/src/widgets/animated_container.dart +++ b/packages/flutter/lib/src/widgets/animated_container.dart @@ -90,11 +90,11 @@ class AnimatedContainerState extends State { AnimatedValue _width; AnimatedValue _height; - AnimationPerformance _performance; + Performance _performance; void initState() { super.initState(); - _performance = new AnimationPerformance(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 { super.dispose(); } - void _updateVariable(AnimatedVariable variable) { + void _updateVariable(Animatable variable) { if (variable != null) _performance.updateVariable(variable); } diff --git a/packages/flutter/lib/src/widgets/dialog.dart b/packages/flutter/lib/src/widgets/dialog.dart index ef142d0baa..54c2a6f174 100644 --- a/packages/flutter/lib/src/widgets/dialog.dart +++ b/packages/flutter/lib/src/widgets/dialog.dart @@ -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(0.0, end: 1.0, curve: easeOut), diff --git a/packages/flutter/lib/src/widgets/dismissable.dart b/packages/flutter/lib/src/widgets/dismissable.dart index 6cb2a78e9b..d019580a68 100644 --- a/packages/flutter/lib/src/widgets/dismissable.dart +++ b/packages/flutter/lib/src/widgets/dismissable.dart @@ -50,15 +50,15 @@ class Dismissable extends StatefulComponent { class DismissableState extends State { void initState() { super.initState(); - _fadePerformance = new AnimationPerformance(duration: _kCardDismissFadeout); - _fadePerformance.addStatusListener((AnimationStatus status) { - if (status == AnimationStatus.completed) + _fadePerformance = new Performance(duration: _kCardDismissFadeout); + _fadePerformance.addStatusListener((PerformanceStatus status) { + if (status == PerformanceStatus.completed) _handleFadeCompleted(); }); } - AnimationPerformance _fadePerformance; - AnimationPerformance _resizePerformance; + Performance _fadePerformance; + Performance _resizePerformance; Size _size; double _dragExtent = 0.0; @@ -97,7 +97,7 @@ class DismissableState extends State { assert(_resizePerformance == null); setState(() { - _resizePerformance = new AnimationPerformance() + _resizePerformance = new Performance() ..duration = _kCardDismissResize ..addListener(_handleResizeProgressChanged); _resizePerformance.play(); @@ -221,7 +221,7 @@ class DismissableState extends State { Widget build(BuildContext context) { if (_resizePerformance != null) { // make sure you remove this widget once it's been dismissed! - assert(_resizePerformance.status == AnimationStatus.forward); + assert(_resizePerformance.status == PerformanceStatus.forward); AnimatedValue squashAxisExtent = new AnimatedValue( _directionIsYAxis ? _size.width : _size.height, diff --git a/packages/flutter/lib/src/widgets/drag_target.dart b/packages/flutter/lib/src/widgets/drag_target.dart index accac1bb13..51800d7891 100644 --- a/packages/flutter/lib/src/widgets/drag_target.dart +++ b/packages/flutter/lib/src/widgets/drag_target.dart @@ -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, diff --git a/packages/flutter/lib/src/widgets/drawer.dart b/packages/flutter/lib/src/widgets/drawer.dart index 5d980b391e..945542c5dd 100644 --- a/packages/flutter/lib/src/widgets/drawer.dart +++ b/packages/flutter/lib/src/widgets/drawer.dart @@ -55,15 +55,15 @@ class Drawer extends StatefulComponent { class DrawerState extends State { void initState() { super.initState(); - _performance = new AnimationPerformance(duration: _kBaseSettleDuration) - ..addStatusListener((AnimationStatus status) { - if (status == AnimationStatus.dismissed) + _performance = new Performance(duration: _kBaseSettleDuration) + ..addStatusListener((PerformanceStatus status) { + if (status == PerformanceStatus.dismissed) config.navigator.pop(); }); _open(); } - AnimationPerformance _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, diff --git a/packages/flutter/lib/src/widgets/ink_well.dart b/packages/flutter/lib/src/widgets/ink_well.dart index a0f36726d1..9abe7745da 100644 --- a/packages/flutter/lib/src/widgets/ink_well.dart +++ b/packages/flutter/lib/src/widgets/ink_well.dart @@ -32,7 +32,7 @@ class InkSplash { _radius = new AnimatedValue( _kSplashInitialSize, end: _targetRadius, curve: easeOut); - _performance = new ValueAnimation( + _performance = new ValuePerformance( variable: _radius, duration: new Duration(milliseconds: (_targetRadius / _kSplashUnconfirmedVelocity).floor()) )..addListener(_handleRadiusChange); @@ -47,7 +47,7 @@ class InkSplash { double _targetRadius; double _pinnedRadius; AnimatedValue _radius; - AnimationPerformance _performance; + Performance _performance; Timer _startTimer; bool _cancelStartTimer() { diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index 55abf1be2c..7df0d8fe0a 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -118,7 +118,7 @@ class NavigatorState extends State { Widget build(BuildContext context) { List visibleRoutes = new List(); 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 { continue; } route.ensurePerformance( - direction: (i <= _currentPosition) ? Direction.forward : Direction.reverse + direction: (i <= _currentPosition) ? AnimationDirection.forward : AnimationDirection.reverse ); route._onDismissed = () { setState(() { @@ -159,28 +159,28 @@ class NavigatorState extends State { abstract class Route { - WatchableAnimationPerformance get performance => _performance?.view; - AnimationPerformance _performance; + PerformanceView get performance => _performance?.view; + Performance _performance; NotificationCallback _onDismissed; - AnimationPerformance createPerformance() { + Performance createPerformance() { Duration duration = transitionDuration; if (duration > Duration.ZERO) { - return new AnimationPerformance(duration: duration) - ..addStatusListener((AnimationStatus status) { - if (status == AnimationStatus.dismissed && _onDismissed != null) + return new Performance(duration: duration) + ..addStatusListener((PerformanceStatus status) { + if (status == PerformanceStatus.dismissed && _onDismissed != null) _onDismissed(); }); } return null; } - void ensurePerformance({ Direction direction }) { + void ensurePerformance({ AnimationDirection direction }) { assert(direction != null); if (_performance == null) _performance = createPerformance(); if (_performance != null) { - AnimationStatus desiredStatus = direction == Direction.forward ? AnimationStatus.forward : AnimationStatus.reverse; + PerformanceStatus desiredStatus = direction == AnimationDirection.forward ? PerformanceStatus.forward : PerformanceStatus.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 [AnimationPerformance] + /// 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; } diff --git a/packages/flutter/lib/src/widgets/popup_menu.dart b/packages/flutter/lib/src/widgets/popup_menu.dart index c06e9539c8..3812fb779a 100644 --- a/packages/flutter/lib/src/widgets/popup_menu.dart +++ b/packages/flutter/lib/src/widgets/popup_menu.dart @@ -44,7 +44,7 @@ class PopupMenu extends StatefulComponent { final List 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; - AnimationPerformance createPerformance() { - AnimationPerformance 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, diff --git a/packages/flutter/lib/src/widgets/progress_indicator.dart b/packages/flutter/lib/src/widgets/progress_indicator.dart index d6c86ef72f..c661fced9e 100644 --- a/packages/flutter/lib/src/widgets/progress_indicator.dart +++ b/packages/flutter/lib/src/widgets/progress_indicator.dart @@ -36,16 +36,16 @@ abstract class ProgressIndicator extends StatefulComponent { class ProgressIndicatorState extends State { - ValueAnimation _performance; + ValuePerformance _performance; void initState() { super.initState(); - _performance = new ValueAnimation( + _performance = new ValuePerformance( variable: new AnimatedValue(0.0, end: 1.0, curve: ease), duration: const Duration(milliseconds: 1500) ); - _performance.addStatusListener((AnimationStatus status) { - if (status == AnimationStatus.completed) + _performance.addStatusListener((PerformanceStatus status) { + if (status == PerformanceStatus.completed) _restartAnimation(); }); _performance.play(); diff --git a/packages/flutter/lib/src/widgets/snack_bar.dart b/packages/flutter/lib/src/widgets/snack_bar.dart index 179e8320ce..757d9a683a 100644 --- a/packages/flutter/lib/src/widgets/snack_bar.dart +++ b/packages/flutter/lib/src/widgets/snack_bar.dart @@ -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 : AnimationDirection.reverse, duration: _kSlideInDuration) { assert(content != null); } diff --git a/packages/flutter/lib/src/widgets/tabs.dart b/packages/flutter/lib/src/widgets/tabs.dart index 19b9c6748b..bcee5e115e 100644 --- a/packages/flutter/lib/src/widgets/tabs.dart +++ b/packages/flutter/lib/src/widgets/tabs.dart @@ -408,16 +408,16 @@ class TabBar extends Scrollable { class TabBarState extends ScrollableState { void initState() { super.initState(); - _indicatorAnimation = new ValueAnimation() + _indicatorAnimation = new ValuePerformance() ..duration = _kTabBarScroll - ..variable = new AnimatedRect(null, curve: ease); + ..variable = new AnimatedRectValue(null, curve: ease); scrollBehavior.isScrollable = config.isScrollable; } Size _tabBarSize; Size _viewportSize = Size.zero; List _tabWidths; - ValueAnimation _indicatorAnimation; + ValuePerformance _indicatorAnimation; void didUpdateConfig(TabBar oldConfig) { super.didUpdateConfig(oldConfig); @@ -425,7 +425,7 @@ class TabBarState extends ScrollableState { scrollTo(0.0); } - AnimatedRect get _indicatorRect => _indicatorAnimation.variable; + AnimatedRectValue get _indicatorRect => _indicatorAnimation.variable; void _startIndicatorAnimation(int fromTabIndex, int toTabIndex) { _indicatorRect diff --git a/packages/flutter/lib/src/widgets/transitions.dart b/packages/flutter/lib/src/widgets/transitions.dart index be14f5d30d..4f00c3694d 100644 --- a/packages/flutter/lib/src/widgets/transitions.dart +++ b/packages/flutter/lib/src/widgets/transitions.dart @@ -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 AnimationDirection; 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);