Chromium Code Reviews| Index: sky/sdk/lib/widgets/animated.dart |
| diff --git a/sky/sdk/lib/widgets/animated.dart b/sky/sdk/lib/widgets/animated.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..46c5388eed51a05b120d19f4ad527824d1bfeffa |
| --- /dev/null |
| +++ b/sky/sdk/lib/widgets/animated.dart |
| @@ -0,0 +1,68 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +import 'package:sky/animation/animation_performance.dart'; |
| +import 'package:sky/widgets/animated_component.dart'; |
| +import 'package:sky/widgets/animation_builder.dart'; |
| +import 'package:sky/widgets/basic.dart'; |
| +import 'package:vector_math/vector_math.dart'; |
| + |
| +class PositionAnimation extends AnimatedComponent { |
|
Matt Perry
2015/07/15 00:20:18
nit: I like AnimatedFoo convention for animated co
|
| + PositionAnimation({ |
| + String key, |
| + this.child, |
| + this.performance, |
| + this.position |
| + }) : super(key: key); |
| + |
| + Widget child; |
| + AnimatedType<Point> position; |
| + AnimationPerformance performance; |
| + |
| + void initState() { |
| + watch(performance); |
| + } |
| + |
| + void syncFields(PositionAnimation source) { |
| + child = source.child; |
| + position = source.position; |
| + assert(performance == source.performance); |
| + } |
| + |
| + Widget build() { |
| + Matrix4 transform = new Matrix4.identity(); |
| + transform.translate(position.value.x, position.value.y); |
| + return new Transform(transform: transform, child: child); |
| + } |
| +} |
| + |
| +class ColorAnimation extends AnimatedComponent { |
| + ColorAnimation({ |
| + String key, |
| + this.child, |
| + this.performance, |
| + this.color |
| + }) : super(key: key); |
| + |
| + Widget child; |
| + AnimatedColor color; |
| + AnimationPerformance performance; |
| + |
| + void initState() { |
| + watch(performance); |
| + } |
| + |
| + void syncFields(ColorAnimation source) { |
| + child = source.child; |
| + color = source.color; |
| + assert(performance == source.performance); |
| + } |
| + |
| + Widget build() { |
| + return new Container( |
| + decoration: new BoxDecoration(backgroundColor: color.value), |
|
Matt Perry
2015/07/15 00:20:18
One of the problems I ran into with animating Mate
abarth-chromium
2015/07/15 00:23:53
Yeah, IMHO ColorAnimation should grow to be Contai
|
| + child: child |
| + ); |
| + } |
| +} |