Commit 3f82552d authored by Adam Barth's avatar Adam Barth

Improves names of animation classes

Fixes #1170
parent bc9d004c
......@@ -60,7 +60,7 @@ class FeedFragment extends StatefulComponent {
class FeedFragmentState extends State<FeedFragment> {
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<FeedFragment> {
setState(() {
_undoItem = item;
_isShowingSnackBar = true;
_snackBarStatus = AnimationStatus.forward;
_snackBarStatus = PerformanceStatus.forward;
});
}
......@@ -207,13 +207,13 @@ class FeedFragmentState extends State<FeedFragment> {
}
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; }); }
);
}
......
......@@ -25,7 +25,7 @@ class StockHomeState extends State<StockHome> {
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<StockHome> {
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;
});
}
......
......@@ -13,7 +13,7 @@ class ProgressIndicatorApp extends StatefulComponent {
class ProgressIndicatorAppState extends State<ProgressIndicatorApp> {
void initState() {
super.initState();
valueAnimation = new ValueAnimation<double>()
valueAnimation = new ValuePerformance<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((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<double> valueAnimation;
Direction valueAnimationDirection = Direction.forward;
ValuePerformance<double> valueAnimation;
AnimationDirection valueAnimationDirection = AnimationDirection.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 == AnimationDirection.forward)
? AnimationDirection.reverse
: AnimationDirection.forward;
valueAnimation.play(valueAnimationDirection);
}
......
......@@ -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';
......
......@@ -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<T extends dynamic> extends AnimationTiming implements AnimatedVariable {
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, AnimationDirection 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 AnimatedRectValue extends AnimatedValue<Rect> {
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);
......
......@@ -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<AnimationPerformanceListener> _listeners = new List<AnimationPerformanceListener>();
final List<PerformanceListener> _listeners = new List<PerformanceListener>();
/// 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<AnimationPerformanceListener> localListeners = new List<AnimationPerformanceListener>.from(_listeners);
for (AnimationPerformanceListener listener in localListeners)
List<PerformanceListener> localListeners = new List<PerformanceListener>.from(_listeners);
for (PerformanceListener listener in localListeners)
listener();
}
final List<AnimationPerformanceStatusListener> _statusListeners = new List<AnimationPerformanceStatusListener>();
final List<PerformanceStatusListener> _statusListeners = new List<PerformanceStatusListener>();
/// 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<AnimationPerformanceStatusListener> localListeners = new List<AnimationPerformanceStatusListener>.from(_statusListeners);
for (AnimationPerformanceStatusListener 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 == 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<T> extends AnimationPerformance {
ValueAnimation({ this.variable, Duration duration, double progress }) :
class ValuePerformance<T> extends Performance {
ValuePerformance({ this.variable, Duration duration, double progress }) :
super(duration: duration, progress: progress);
AnimatedValue<T> variable;
......
......@@ -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;
}
......
......@@ -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 AnimationPerformance(duration: _kShowDuration)
_showPerformance = new Performance(duration: _kShowDuration)
..addListener(() {
_showPerformance.updateVariable(_outerOpacity);
_showPerformance.updateVariable(_innerCenter);
_showPerformance.updateVariable(_innerRadius);
});
_fade = new ValueAnimation<double>(
_fade = new ValuePerformance<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;
AnimationPerformance _showPerformance;
Performance _showPerformance;
AnimatedValue<double> _outerOpacity;
AnimatedValue<Point> _innerCenter;
AnimatedValue<double> _innerRadius;
Future _showComplete;
ValueAnimation<double> _fade;
ValuePerformance<double> _fade;
/// Show the reaction
///
......
......@@ -24,15 +24,15 @@ abstract class RenderToggleable extends RenderConstrainedBox {
: _value = value,
_onChanged = onChanged,
super(additionalConstraints: new BoxConstraints.tight(size)) {
_performance = new ValueAnimation<double>(
_performance = new ValuePerformance<double>(
variable: new AnimatedValue<double>(0.0, end: 1.0, curve: easeIn, reverseCurve: easeOut),
duration: _kToggleDuration,
progress: _value ? 1.0 : 0.0
)..addListener(markNeedsPaint);
}
ValueAnimation<double> get performance => _performance;
ValueAnimation<double> _performance;
ValuePerformance<double> get performance => _performance;
ValuePerformance<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 : AnimationDirection.reverse);
}
ValueChanged get onChanged => _onChanged;
......
......@@ -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<T extends AnimatedComponent> extends State<T> {
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<T extends AnimatedComponent> extends State<T> {
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();
}
......
......@@ -90,11 +90,11 @@ class AnimatedContainerState extends State<AnimatedContainer> {
AnimatedValue<double> _width;
AnimatedValue<double> _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<AnimatedContainer> {
super.dispose();
}
void _updateVariable(AnimatedVariable variable) {
void _updateVariable(Animatable variable) {
if (variable != null)
_performance.updateVariable(variable);
}
......
......@@ -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),
......
......@@ -50,15 +50,15 @@ class Dismissable extends StatefulComponent {
class DismissableState extends State<Dismissable> {
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<Dismissable> {
assert(_resizePerformance == null);
setState(() {
_resizePerformance = new AnimationPerformance()
_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 == AnimationStatus.forward);
assert(_resizePerformance.status == PerformanceStatus.forward);
AnimatedValue<double> squashAxisExtent = new AnimatedValue<double>(
_directionIsYAxis ? _size.width : _size.height,
......
......@@ -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,
......
......@@ -55,15 +55,15 @@ class Drawer extends StatefulComponent {
class DrawerState extends State<Drawer> {
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,
......
......@@ -32,7 +32,7 @@ class InkSplash {
_radius = new AnimatedValue<double>(
_kSplashInitialSize, end: _targetRadius, curve: easeOut);
_performance = new ValueAnimation<double>(
_performance = new ValuePerformance<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;
AnimationPerformance _performance;
Performance _performance;
Timer _startTimer;
bool _cancelStartTimer() {
......
......@@ -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 : AnimationDirection.reverse
);
route._onDismissed = () {
setState(() {
......@@ -159,28 +159,28 @@ class NavigatorState extends State<Navigator> {
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;
}
......@@ -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;
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,
......
......@@ -36,16 +36,16 @@ abstract class ProgressIndicator extends StatefulComponent {
class ProgressIndicatorState extends State<ProgressIndicator> {
ValueAnimation<double> _performance;
ValuePerformance<double> _performance;
void initState() {
super.initState();
_performance = new ValueAnimation<double>(
_performance = new ValuePerformance<double>(
variable: new AnimatedValue<double>(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();
......
......@@ -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);
}
......
......@@ -408,16 +408,16 @@ class TabBar extends Scrollable {
class TabBarState extends ScrollableState<TabBar> {
void initState() {
super.initState();
_indicatorAnimation = new ValueAnimation<Rect>()
_indicatorAnimation = new ValuePerformance<Rect>()
..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<double> _tabWidths;
ValueAnimation<Rect> _indicatorAnimation;
ValuePerformance<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;
AnimatedRectValue get _indicatorRect => _indicatorAnimation.variable;
void _startIndicatorAnimation(int fromTabIndex, int toTabIndex) {
_indicatorRect
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment