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

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

Issue 1177383006: Rename all the things (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fix imports Created 5 years, 6 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
(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 'dart:async';
6
7 import '../animation/animated_value.dart';
8 import 'basic.dart';
9
10 typedef void SetterFunction(double value);
11
12 class _AnimationEntry {
13 _AnimationEntry(this.value, this.setter);
14 final AnimatedValue value;
15 final SetterFunction setter;
16 StreamSubscription<double> subscription;
17 }
18
19 abstract class AnimatedComponent extends Component {
20
21 AnimatedComponent({ Object key }) : super(key: key, stateful: true);
22
23 void syncFields(AnimatedComponent source) { }
24
25 List<_AnimationEntry> _animatedFields = new List<_AnimationEntry>();
26
27 animate(AnimatedValue value, SetterFunction setter) {
28 assert(!mounted);
29 setter(value.value);
30 _animatedFields.add(new _AnimationEntry(value, setter));
31 }
32
33 void didMount() {
34 for (_AnimationEntry entry in _animatedFields) {
35 entry.subscription = entry.value.onValueChanged.listen((_) {
36 entry.setter(entry.value.value);
37 scheduleBuild();
38 });
39 }
40 super.didMount();
41 }
42
43 void didUnmount() {
44 for (_AnimationEntry entry in _animatedFields) {
45 assert(entry.subscription != null);
46 entry.subscription.cancel();
47 entry.subscription = null;
48 }
49 super.didUnmount();
50 }
51
52 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/theme2/view_configuration.dart ('k') | sky/sdk/lib/framework/widgets/basic.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698