Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 import 'package:sky/animation/animation_performance.dart'; | |
| 6 import 'package:sky/widgets/animated_component.dart'; | |
| 7 import 'package:sky/widgets/animation_builder.dart'; | |
| 8 import 'package:sky/widgets/basic.dart'; | |
| 9 import 'package:vector_math/vector_math.dart'; | |
| 10 | |
| 11 class PositionAnimation extends AnimatedComponent { | |
|
Matt Perry
2015/07/15 00:20:18
nit: I like AnimatedFoo convention for animated co
| |
| 12 PositionAnimation({ | |
| 13 String key, | |
| 14 this.child, | |
| 15 this.performance, | |
| 16 this.position | |
| 17 }) : super(key: key); | |
| 18 | |
| 19 Widget child; | |
| 20 AnimatedType<Point> position; | |
| 21 AnimationPerformance performance; | |
| 22 | |
| 23 void initState() { | |
| 24 watch(performance); | |
| 25 } | |
| 26 | |
| 27 void syncFields(PositionAnimation source) { | |
| 28 child = source.child; | |
| 29 position = source.position; | |
| 30 assert(performance == source.performance); | |
| 31 } | |
| 32 | |
| 33 Widget build() { | |
| 34 Matrix4 transform = new Matrix4.identity(); | |
| 35 transform.translate(position.value.x, position.value.y); | |
| 36 return new Transform(transform: transform, child: child); | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 class ColorAnimation extends AnimatedComponent { | |
| 41 ColorAnimation({ | |
| 42 String key, | |
| 43 this.child, | |
| 44 this.performance, | |
| 45 this.color | |
| 46 }) : super(key: key); | |
| 47 | |
| 48 Widget child; | |
| 49 AnimatedColor color; | |
| 50 AnimationPerformance performance; | |
| 51 | |
| 52 void initState() { | |
| 53 watch(performance); | |
| 54 } | |
| 55 | |
| 56 void syncFields(ColorAnimation source) { | |
| 57 child = source.child; | |
| 58 color = source.color; | |
| 59 assert(performance == source.performance); | |
| 60 } | |
| 61 | |
| 62 Widget build() { | |
| 63 return new Container( | |
| 64 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
| |
| 65 child: child | |
| 66 ); | |
| 67 } | |
| 68 } | |
| OLD | NEW |