Move animation curves into a Curves namespace
diff --git a/examples/game/test_physics.dart b/examples/game/test_physics.dart index b645d36..5c22c30 100644 --- a/examples/game/test_physics.dart +++ b/examples/game/test_physics.dart
@@ -67,14 +67,14 @@ // Animate obstacle ActionSequence seq = new ActionSequence([ - new ActionTween((a) => _obstacle.position = a, new Point(256.0, 800.0), new Point(768.0, 800.0), 1.0, easeInOut), - new ActionTween((a) => _obstacle.position = a, new Point(768.0, 800.0), new Point(256.0, 800.0), 1.0, easeInOut) + new ActionTween((a) => _obstacle.position = a, new Point(256.0, 800.0), new Point(768.0, 800.0), 1.0, Curves.easeInOut), + new ActionTween((a) => _obstacle.position = a, new Point(768.0, 800.0), new Point(256.0, 800.0), 1.0, Curves.easeInOut) ]); _obstacle.actions.run(new ActionRepeatForever(seq)); seq = new ActionSequence([ - new ActionTween((a) => _obstacle.scale = a, 1.0, 2.0, 2.0, easeInOut), - new ActionTween((a) => _obstacle.scale = a, 2.0, 1.0, 2.0, easeInOut) + new ActionTween((a) => _obstacle.scale = a, 1.0, 2.0, 2.0, Curves.easeInOut), + new ActionTween((a) => _obstacle.scale = a, 2.0, 1.0, 2.0, Curves.easeInOut) ]); _obstacle.actions.run(new ActionRepeatForever(seq));
diff --git a/examples/widgets/progress_indicator.dart b/examples/widgets/progress_indicator.dart index 392d52a..b28f6cb 100644 --- a/examples/widgets/progress_indicator.dart +++ b/examples/widgets/progress_indicator.dart
@@ -17,8 +17,8 @@ ..variable = new AnimatedValue<double>( 0.0, end: 1.0, - curve: new Interval(0.0, 0.9, curve: ease), - reverseCurve: ease + curve: new Interval(0.0, 0.9, curve: Curves.ease), + reverseCurve: Curves.ease ); valueAnimation.addStatusListener((PerformanceStatus status) { if (status == PerformanceStatus.dismissed || status == PerformanceStatus.completed)
diff --git a/sky/packages/sky/lib/src/animation/curves.dart b/sky/packages/sky/lib/src/animation/curves.dart index 5b44cc4..3d0f6f5 100644 --- a/sky/packages/sky/lib/src/animation/curves.dart +++ b/sky/packages/sky/lib/src/animation/curves.dart
@@ -29,7 +29,7 @@ /// A curve that is 0.0 until start, then curved from 0.0 to 1.0 at end, then 1.0 class Interval implements Curve { - const Interval(this.start, this.end, { this.curve: linear }); + const Interval(this.start, this.end, { this.curve: Curves.linear }); /// The smallest value for which this interval is 0.0 final double start; @@ -153,38 +153,43 @@ } } -/// A linear animation curve -const Linear linear = const Linear(); +/// A collection of common animation curves. +class Curves { + Curves._(); -/// A cubic animation curve that speeds up quickly and ends slowly -const Cubic ease = const Cubic(0.25, 0.1, 0.25, 1.0); + /// A linear animation curve + static const Linear linear = const Linear(); -/// A cubic animation curve that starts slowly and ends quickly -const Cubic easeIn = const Cubic(0.42, 0.0, 1.0, 1.0); + /// A cubic animation curve that speeds up quickly and ends slowly + static const Cubic ease = const Cubic(0.25, 0.1, 0.25, 1.0); -/// A cubic animation curve that starts quickly and ends slowly -const Cubic easeOut = const Cubic(0.0, 0.0, 0.58, 1.0); + /// A cubic animation curve that starts slowly and ends quickly + static const Cubic easeIn = const Cubic(0.42, 0.0, 1.0, 1.0); -/// A cubic animation curve that starts slowly, speeds up, and then and ends slowly -const Cubic easeInOut = const Cubic(0.42, 0.0, 0.58, 1.0); + /// A cubic animation curve that starts quickly and ends slowly + static const Cubic easeOut = const Cubic(0.0, 0.0, 0.58, 1.0); -/// An oscillating curve that grows in magnitude -const BounceInCurve bounceIn = const BounceInCurve(); + /// A cubic animation curve that starts slowly, speeds up, and then and ends slowly + static const Cubic easeInOut = const Cubic(0.42, 0.0, 0.58, 1.0); -/// An oscillating curve that first grows and then shrink in magnitude -const BounceOutCurve bounceOut = const BounceOutCurve(); + /// An oscillating curve that grows in magnitude + static const BounceInCurve bounceIn = const BounceInCurve(); -/// An oscillating curve that first grows and then shrink in magnitude -const BounceInOutCurve bounceInOut = const BounceInOutCurve(); + /// An oscillating curve that first grows and then shrink in magnitude + static const BounceOutCurve bounceOut = const BounceOutCurve(); -/// An oscillating curve that grows in magnitude while overshootings its bounds -const ElasticInCurve elasticIn = const ElasticInCurve(); + /// An oscillating curve that first grows and then shrink in magnitude + static const BounceInOutCurve bounceInOut = const BounceInOutCurve(); -/// An oscillating curve that shrinks in magnitude while overshootings its bounds -const ElasticOutCurve elasticOut = const ElasticOutCurve(); + /// An oscillating curve that grows in magnitude while overshootings its bounds + static const ElasticInCurve elasticIn = const ElasticInCurve(); -/// An oscillating curve that grows and then shrinks in magnitude while overshootings its bounds -const ElasticInOutCurve elasticInOut = const ElasticInOutCurve(); + /// An oscillating curve that shrinks in magnitude while overshootings its bounds + static const ElasticOutCurve elasticOut = const ElasticOutCurve(); -/// A curve that starts quickly and eases into its final position. Over the course of the animation, the object spends more time near its final destination. As a result, the user isn’t left waiting for the animation to finish, and the negative effects of motion are minimized. -const Curve fastOutSlowIn = const Cubic(0.4, 0.0, 0.2, 1.0); + /// An oscillating curve that grows and then shrinks in magnitude while overshootings its bounds + static const ElasticInOutCurve elasticInOut = const ElasticInOutCurve(); + + /// A curve that starts quickly and eases into its final position. Over the course of the animation, the object spends more time near its final destination. As a result, the user isn’t left waiting for the animation to finish, and the negative effects of motion are minimized. + static const Curve fastOutSlowIn = const Cubic(0.4, 0.0, 0.2, 1.0); +}
diff --git a/sky/packages/sky/lib/src/animation/simulation_stepper.dart b/sky/packages/sky/lib/src/animation/simulation_stepper.dart index 843be0a..44d6a6a 100644 --- a/sky/packages/sky/lib/src/animation/simulation_stepper.dart +++ b/sky/packages/sky/lib/src/animation/simulation_stepper.dart
@@ -66,7 +66,7 @@ /// /// Returns a future that resolves when the timeline stops animating, /// typically when the timeline arives at the target value. - Future animateTo(double target, { Duration duration, Curve curve: linear }) { + Future animateTo(double target, { Duration duration, Curve curve: Curves.linear }) { assert(duration > Duration.ZERO); assert(!isAnimating); return _start(new _TweenSimulation(value, target, duration, curve));
diff --git a/sky/packages/sky/lib/src/material/dialog.dart b/sky/packages/sky/lib/src/material/dialog.dart index 6bf57ba..bb61579 100644 --- a/sky/packages/sky/lib/src/material/dialog.dart +++ b/sky/packages/sky/lib/src/material/dialog.dart
@@ -142,7 +142,7 @@ Widget build(NavigatorState navigator, PerformanceView nextRoutePerformance) { return new FadeTransition( performance: performance, - opacity: new AnimatedValue<double>(0.0, end: 1.0, curve: easeOut), + opacity: new AnimatedValue<double>(0.0, end: 1.0, curve: Curves.easeOut), child: builder(new RouteArguments(navigator: navigator, previousPerformance: this.performance, nextPerformance: nextRoutePerformance)) ); }
diff --git a/sky/packages/sky/lib/src/material/drawer.dart b/sky/packages/sky/lib/src/material/drawer.dart index 35ea2ef..d0dcdcb 100644 --- a/sky/packages/sky/lib/src/material/drawer.dart +++ b/sky/packages/sky/lib/src/material/drawer.dart
@@ -83,7 +83,7 @@ performance: performance, position: new AnimatedValue<Point>(_kClosedPosition, end: _kOpenPosition), child: new AnimatedContainer( - curve: ease, + curve: Curves.ease, duration: _kThemeChangeDuration, decoration: new BoxDecoration( backgroundColor: Theme.of(context).canvasColor,
diff --git a/sky/packages/sky/lib/src/material/ink_well.dart b/sky/packages/sky/lib/src/material/ink_well.dart index bc4bb23..0d5ca2d 100644 --- a/sky/packages/sky/lib/src/material/ink_well.dart +++ b/sky/packages/sky/lib/src/material/ink_well.dart
@@ -28,7 +28,7 @@ _InkSplash(this.position, this.well) { _targetRadius = _getSplashTargetSize(well.size, position); _radius = new AnimatedValue<double>( - _kSplashInitialSize, end: _targetRadius, curve: easeOut); + _kSplashInitialSize, end: _targetRadius, curve: Curves.easeOut); _performance = new ValuePerformance<double>( variable: _radius,
diff --git a/sky/packages/sky/lib/src/material/material.dart b/sky/packages/sky/lib/src/material/material.dart index 893d478..96ada6f 100644 --- a/sky/packages/sky/lib/src/material/material.dart +++ b/sky/packages/sky/lib/src/material/material.dart
@@ -67,7 +67,7 @@ return new DefaultTextStyle( style: Theme.of(context).text.body1, child: new AnimatedContainer( - curve: ease, + curve: Curves.ease, duration: kThemeChangeDuration, decoration: new BoxDecoration( backgroundColor: _getBackgroundColor(context),
diff --git a/sky/packages/sky/lib/src/material/progress_indicator.dart b/sky/packages/sky/lib/src/material/progress_indicator.dart index 1fd6a71..ac41cf2 100644 --- a/sky/packages/sky/lib/src/material/progress_indicator.dart +++ b/sky/packages/sky/lib/src/material/progress_indicator.dart
@@ -45,7 +45,7 @@ void initState() { super.initState(); _performance = new ValuePerformance<double>( - variable: new AnimatedValue<double>(0.0, end: 1.0, curve: ease), + variable: new AnimatedValue<double>(0.0, end: 1.0, curve: Curves.ease), duration: const Duration(milliseconds: 1500) ); _performance.addStatusListener((PerformanceStatus status) {
diff --git a/sky/packages/sky/lib/src/material/radial_reaction.dart b/sky/packages/sky/lib/src/material/radial_reaction.dart index 8e73496..7d550b6 100644 --- a/sky/packages/sky/lib/src/material/radial_reaction.dart +++ b/sky/packages/sky/lib/src/material/radial_reaction.dart
@@ -26,9 +26,9 @@ this.radius, Point startPosition }) { - _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); + _outerOpacity = new AnimatedValue<double>(0.0, end: _kMaxOpacity, curve: Curves.easeOut); + _innerCenter = new AnimatedValue<Point>(startPosition, end: center, curve: Curves.easeOut); + _innerRadius = new AnimatedValue<double>(0.0, end: radius, curve: Curves.easeOut); _showPerformance = new Performance(duration: _kShowDuration) ..addListener(() { _showPerformance.updateVariable(_outerOpacity); @@ -36,7 +36,7 @@ _showPerformance.updateVariable(_innerRadius); }); _fade = new ValuePerformance<double>( - variable: new AnimatedValue<double>(1.0, end: 0.0, curve: easeIn), + variable: new AnimatedValue<double>(1.0, end: 0.0, curve: Curves.easeIn), duration: _kHideDuration ); }
diff --git a/sky/packages/sky/lib/src/material/scrollbar_painter.dart b/sky/packages/sky/lib/src/material/scrollbar_painter.dart index cd839f4..5eb8f72 100644 --- a/sky/packages/sky/lib/src/material/scrollbar_painter.dart +++ b/sky/packages/sky/lib/src/material/scrollbar_painter.dart
@@ -62,7 +62,7 @@ Future scrollStarted() { _fade ??= new ValuePerformance<double>() ..duration = _kScrollbarThumbFadeDuration - ..variable = new AnimatedValue<double>(0.0, end: 1.0, curve: ease) + ..variable = new AnimatedValue<double>(0.0, end: 1.0, curve: Curves.ease) ..addListener(() { _opacity = _fade.value; renderer?.markNeedsPaint();
diff --git a/sky/packages/sky/lib/src/material/snack_bar.dart b/sky/packages/sky/lib/src/material/snack_bar.dart index 8ec933a..340174d 100644 --- a/sky/packages/sky/lib/src/material/snack_bar.dart +++ b/sky/packages/sky/lib/src/material/snack_bar.dart
@@ -67,8 +67,8 @@ height: new AnimatedValue<double>( 0.0, end: kSnackBarHeight, - curve: easeIn, - reverseCurve: easeOut + curve: Curves.easeIn, + reverseCurve: Curves.easeOut ), child: new ClipRect( child: new OverflowBox(
diff --git a/sky/packages/sky/lib/src/material/tabs.dart b/sky/packages/sky/lib/src/material/tabs.dart index dcb9174..da976a0 100644 --- a/sky/packages/sky/lib/src/material/tabs.dart +++ b/sky/packages/sky/lib/src/material/tabs.dart
@@ -404,7 +404,7 @@ super.initState(); _indicatorAnimation = new ValuePerformance<Rect>() ..duration = _kTabBarScroll - ..variable = new AnimatedRectValue(null, curve: ease); + ..variable = new AnimatedRectValue(null, curve: Curves.ease); scrollBehavior.isScrollable = config.isScrollable; }
diff --git a/sky/packages/sky/lib/src/rendering/toggleable.dart b/sky/packages/sky/lib/src/rendering/toggleable.dart index f6e7879..658f65d 100644 --- a/sky/packages/sky/lib/src/rendering/toggleable.dart +++ b/sky/packages/sky/lib/src/rendering/toggleable.dart
@@ -24,7 +24,7 @@ _onChanged = onChanged, super(additionalConstraints: new BoxConstraints.tight(size)) { _performance = new ValuePerformance<double>( - variable: new AnimatedValue<double>(0.0, end: 1.0, curve: easeIn, reverseCurve: easeOut), + variable: new AnimatedValue<double>(0.0, end: 1.0, curve: Curves.easeIn, reverseCurve: Curves.easeOut), duration: _kToggleDuration, progress: _value ? 1.0 : 0.0 )..addListener(markNeedsPaint);
diff --git a/sky/packages/sky/lib/src/widgets/animated_container.dart b/sky/packages/sky/lib/src/widgets/animated_container.dart index f205fdd..8a1831b 100644 --- a/sky/packages/sky/lib/src/widgets/animated_container.dart +++ b/sky/packages/sky/lib/src/widgets/animated_container.dart
@@ -56,7 +56,7 @@ this.transform, this.width, this.height, - this.curve: linear, + this.curve: Curves.linear, this.duration }) : super(key: key) { assert(margin == null || margin.isNonNegative);
diff --git a/sky/packages/sky/lib/src/widgets/dismissable.dart b/sky/packages/sky/lib/src/widgets/dismissable.dart index f16c653..a59c01f 100644 --- a/sky/packages/sky/lib/src/widgets/dismissable.dart +++ b/sky/packages/sky/lib/src/widgets/dismissable.dart
@@ -13,7 +13,7 @@ const Duration _kCardDismissFadeout = const Duration(milliseconds: 200); const Duration _kCardDismissResize = const Duration(milliseconds: 300); -const Curve _kCardDismissResizeCurve = const Interval(0.4, 1.0, curve: ease); +const Curve _kCardDismissResizeCurve = const Interval(0.4, 1.0, curve: Curves.ease); const double _kMinFlingVelocity = 700.0; const double _kMinFlingVelocityDelta = 400.0; const double _kFlingVelocityScale = 1.0 / 300.0;
diff --git a/sky/packages/sky/lib/src/widgets/navigator.dart b/sky/packages/sky/lib/src/widgets/navigator.dart index d708f4b..358cab0 100644 --- a/sky/packages/sky/lib/src/widgets/navigator.dart +++ b/sky/packages/sky/lib/src/widgets/navigator.dart
@@ -307,10 +307,10 @@ // TODO(jackson): Block input unless content is interactive return new SlideTransition( performance: performance, - position: new AnimatedValue<Point>(_kTransitionStartPoint, end: Point.origin, curve: easeOut), + position: new AnimatedValue<Point>(_kTransitionStartPoint, end: Point.origin, curve: Curves.easeOut), child: new FadeTransition( performance: performance, - opacity: new AnimatedValue<double>(0.0, end: 1.0, curve: easeOut), + opacity: new AnimatedValue<double>(0.0, end: 1.0, curve: Curves.easeOut), child: builder(new RouteArguments(navigator: navigator, previousPerformance: this.performance, nextPerformance: nextRoutePerformance)) ) );
diff --git a/sky/packages/sky/lib/src/widgets/scrollable.dart b/sky/packages/sky/lib/src/widgets/scrollable.dart index ea1cbf4..a517dd5 100644 --- a/sky/packages/sky/lib/src/widgets/scrollable.dart +++ b/sky/packages/sky/lib/src/widgets/scrollable.dart
@@ -181,7 +181,7 @@ dispatchOnScroll(); } - Future scrollTo(double newScrollOffset, { Duration duration, Curve curve: ease }) { + Future scrollTo(double newScrollOffset, { Duration duration, Curve curve: Curves.ease }) { if (newScrollOffset == _scrollOffset) return new Future.value(); @@ -692,7 +692,7 @@ this.onPageChanged, EdgeDims padding, this.duration: const Duration(milliseconds: 200), - this.curve: ease + this.curve: Curves.ease }) : super( key: key, initialScrollOffset: initialPage == null ? null : initialPage * itemExtent,
diff --git a/sky/unit/test/widget/positioned_test.dart b/sky/unit/test/widget/positioned_test.dart index 7adecc8..d6bcb0e 100644 --- a/sky/unit/test/widget/positioned_test.dart +++ b/sky/unit/test/widget/positioned_test.dart
@@ -19,7 +19,7 @@ new Rect.fromLTRB(80.0, 90.0, 90.0, 100.0), new Rect.fromLTRB(0.0, 10.0, 100.0, 110.0) ), - curve: linear + curve: Curves.linear ); final Performance performance = new Performance( duration: const Duration(seconds: 10)