Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Side by Side Diff: sky/sdk/lib/widgets/animated_component.dart

Issue 1211603003: Baby steps towards an odeon-like animation system. First victim: Drawer. (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: widget builder Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:vector_math/vector_math.dart';
8
7 import '../animation/animated_value.dart'; 9 import '../animation/animated_value.dart';
10 import '../animation/animation_performance.dart';
11 import '../animation/curves.dart';
8 import 'basic.dart'; 12 import 'basic.dart';
9 13
10 class _AnimationEntry { 14 class _AnimationEntry {
11 _AnimationEntry(this.value); 15 _AnimationEntry(this.value);
12 final AnimatedValue value; 16 final AnimatedValue value;
13 StreamSubscription<double> subscription; 17 StreamSubscription<double> subscription;
14 } 18 }
15 19
16 abstract class AnimatedComponent extends Component { 20 abstract class AnimatedComponent extends Component {
17 21
(...skipping 25 matching lines...) Expand all
43 void didUnmount() { 47 void didUnmount() {
44 for (_AnimationEntry entry in _animatedFields) { 48 for (_AnimationEntry entry in _animatedFields) {
45 assert(entry.subscription != null); 49 assert(entry.subscription != null);
46 entry.subscription.cancel(); 50 entry.subscription.cancel();
47 entry.subscription = null; 51 entry.subscription = null;
48 } 52 }
49 super.didUnmount(); 53 super.didUnmount();
50 } 54 }
51 55
52 } 56 }
57
58 // Types of things that can be animated in a component. Use build() to
59 // construct the final Widget based on the animation state.
60 // TODO(mpcomplete): the idea here is to eventually have an AnimatedCollection
61 // which assembles a container based on a list of animated things. e.g. if you
62 // want to animate position, opacity, and shadow, you add those animators to an
63 // AnimatedCollection and just call collection.build() to construct your
64 // widget.
65
66 class AnimatedPosition extends AnimatedType<Point> {
67 AnimatedPosition(Point begin, Point end, {Curve curve: linear})
68 : super(begin, end, curve: curve);
69
70 Widget build({Widget child}) {
71 Matrix4 transform = new Matrix4.identity();
72 transform.translate(value.x, value.y);
73 return new Transform(transform: transform, child: child);
74 }
75 }
abarth-chromium 2015/06/30 22:26:09 Why not make an AnimatedTransform that inherits fr
Matt Perry 2015/07/01 18:17:43 My goal is to make it so the user doesn't have to
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698