Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:sky/animation/animation_performance.dart'; | 5 import 'package:sky/animation/animation_performance.dart'; |
| 6 import 'package:sky/widgets/animated_component.dart'; | 6 import 'package:sky/widgets/animated_component.dart'; |
| 7 import 'package:sky/widgets/animation_builder.dart'; | 7 import 'package:sky/widgets/animation_builder.dart'; |
| 8 import 'package:sky/widgets/basic.dart'; | 8 import 'package:sky/widgets/basic.dart'; |
| 9 import 'package:vector_math/vector_math.dart'; | 9 import 'package:vector_math/vector_math.dart'; |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 assert(performance == source.performance); | 30 assert(performance == source.performance); |
| 31 } | 31 } |
| 32 | 32 |
| 33 Widget build() { | 33 Widget build() { |
| 34 Matrix4 transform = new Matrix4.identity(); | 34 Matrix4 transform = new Matrix4.identity(); |
| 35 transform.translate(position.value.x, position.value.y); | 35 transform.translate(position.value.x, position.value.y); |
| 36 return new Transform(transform: transform, child: child); | 36 return new Transform(transform: transform, child: child); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 class OpacityAnimation extends AnimatedComponent { | |
| 41 OpacityAnimation({ | |
| 42 String key, | |
| 43 this.child, | |
| 44 this.performance, | |
| 45 this.opacity | |
| 46 }) : super(key: key); | |
| 47 | |
| 48 Widget child; | |
| 49 AnimatedType<double> opacity; | |
| 50 AnimationPerformance performance; | |
| 51 | |
| 52 void initState() { | |
| 53 watch(performance); | |
|
Matt Perry
2015/07/15 00:27:26
maybe have all of these inherit from a common base
| |
| 54 } | |
| 55 | |
| 56 void syncFields(OpacityAnimation source) { | |
| 57 child = source.child; | |
| 58 opacity = source.opacity; | |
| 59 assert(performance == source.performance); | |
| 60 } | |
| 61 | |
| 62 Widget build() { | |
| 63 return new Opacity(opacity: opacity.value, child: child); | |
| 64 } | |
| 65 } | |
| 66 | |
| 40 class ColorAnimation extends AnimatedComponent { | 67 class ColorAnimation extends AnimatedComponent { |
| 41 ColorAnimation({ | 68 ColorAnimation({ |
| 42 String key, | 69 String key, |
| 43 this.child, | 70 this.child, |
| 44 this.performance, | 71 this.performance, |
| 45 this.color | 72 this.color |
| 46 }) : super(key: key); | 73 }) : super(key: key); |
| 47 | 74 |
| 48 Widget child; | 75 Widget child; |
| 49 AnimatedColor color; | 76 AnimatedColor color; |
| 50 AnimationPerformance performance; | 77 AnimationPerformance performance; |
| 51 | 78 |
| 52 void initState() { | 79 void initState() { |
| 53 watch(performance); | 80 watch(performance); |
| 54 } | 81 } |
| 55 | 82 |
| 56 void syncFields(ColorAnimation source) { | 83 void syncFields(ColorAnimation source) { |
| 57 child = source.child; | 84 child = source.child; |
| 58 color = source.color; | 85 color = source.color; |
| 59 assert(performance == source.performance); | 86 assert(performance == source.performance); |
| 60 } | 87 } |
| 61 | 88 |
| 62 Widget build() { | 89 Widget build() { |
| 63 return new Container( | 90 return new Container( |
| 64 decoration: new BoxDecoration(backgroundColor: color.value), | 91 decoration: new BoxDecoration(backgroundColor: color.value), |
| 65 child: child | 92 child: child |
| 66 ); | 93 ); |
| 67 } | 94 } |
| 68 } | 95 } |
| OLD | NEW |