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

Unified Diff: sky/sdk/lib/widgets/animated_component.dart

Issue 1226263003: Break dependency of AnimationPerformance on AnimatedValue (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: remove unused import 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/lib/animation/timeline.dart ('k') | sky/sdk/lib/widgets/drawer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/widgets/animated_component.dart
diff --git a/sky/sdk/lib/widgets/animated_component.dart b/sky/sdk/lib/widgets/animated_component.dart
index af088f846434d415523be11d13d2aaef0ef8bb14..526c2ba6a5ef1c7bcd6123162a68a664c4562a87 100644
--- a/sky/sdk/lib/widgets/animated_component.dart
+++ b/sky/sdk/lib/widgets/animated_component.dart
@@ -23,9 +23,10 @@ abstract class AnimatedComponent extends StatefulComponent {
void syncFields(AnimatedComponent source) { }
- List<_AnimationEntry> _animatedFields = new List<_AnimationEntry>();
+ final List<_AnimationEntry> _animatedFields = new List<_AnimationEntry>();
+ final List<AnimationPerformance> _watchedPerformances = new List<AnimationPerformance>();
- watch(AnimatedValue value) {
+ void watch(AnimatedValue value) {
assert(!mounted);
// TODO(ianh): we really should assert that we're not doing this
// in the constructor since doing it there is pointless and
@@ -35,12 +36,22 @@ abstract class AnimatedComponent extends StatefulComponent {
_animatedFields.add(new _AnimationEntry(value));
}
+ void watchPerformance(AnimationPerformance performance) {
+ assert(!mounted);
+ assert(!_watchedPerformances.contains(performance));
+ _watchedPerformances.add(performance);
+ }
+
void didMount() {
for (_AnimationEntry entry in _animatedFields) {
entry.subscription = entry.value.onValueChanged.listen((_) {
scheduleBuild();
});
}
+
+ for (AnimationPerformance performance in _watchedPerformances)
+ performance.addListener(scheduleBuild);
+
super.didMount();
}
@@ -50,6 +61,10 @@ abstract class AnimatedComponent extends StatefulComponent {
entry.subscription.cancel();
entry.subscription = null;
}
+
+ for (AnimationPerformance performance in _watchedPerformances)
+ performance.removeListener(scheduleBuild);
+
super.didUnmount();
}
« no previous file with comments | « sky/sdk/lib/animation/timeline.dart ('k') | sky/sdk/lib/widgets/drawer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698