| 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/basic.dart'; | 6 import 'package:sky/widgets/basic.dart'; |
| 7 | 7 |
| 8 abstract class AnimatedComponent extends StatefulComponent { | 8 abstract class AnimatedComponent extends StatefulComponent { |
| 9 | 9 |
| 10 AnimatedComponent({ String key }) : super(key: key); | 10 AnimatedComponent({ String key }) : super(key: key); |
| 11 | 11 |
| 12 void syncFields(AnimatedComponent source) { } | 12 void syncFields(AnimatedComponent source) { } |
| 13 | 13 |
| 14 final List<AnimationPerformance> _watchedPerformances = new List<AnimationPerf
ormance>(); | 14 final List<AnimationPerformance> _watchedPerformances = new List<AnimationPerf
ormance>(); |
| 15 | 15 |
| 16 void watchPerformance(AnimationPerformance performance) { | 16 void watch(AnimationPerformance performance) { |
| 17 assert(!_watchedPerformances.contains(performance)); | 17 assert(!_watchedPerformances.contains(performance)); |
| 18 _watchedPerformances.add(performance); | 18 _watchedPerformances.add(performance); |
| 19 if (mounted) | 19 if (mounted) |
| 20 performance.addListener(scheduleBuild); | 20 performance.addListener(scheduleBuild); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void didMount() { | 23 void didMount() { |
| 24 for (AnimationPerformance performance in _watchedPerformances) | 24 for (AnimationPerformance performance in _watchedPerformances) |
| 25 performance.addListener(scheduleBuild); | 25 performance.addListener(scheduleBuild); |
| 26 super.didMount(); | 26 super.didMount(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void didUnmount() { | 29 void didUnmount() { |
| 30 for (AnimationPerformance performance in _watchedPerformances) | 30 for (AnimationPerformance performance in _watchedPerformances) |
| 31 performance.removeListener(scheduleBuild); | 31 performance.removeListener(scheduleBuild); |
| 32 super.didUnmount(); | 32 super.didUnmount(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 } | 35 } |
| OLD | NEW |