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

Unified Diff: sky/framework/animation/animated_value.dart

Issue 1016093002: Begin work on the PopupMenu entrance animation (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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/examples/stocks-fn/lib/stock_app.dart ('k') | sky/framework/animation/animation.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/animation/animated_value.dart
diff --git a/sky/framework/animation/animation.dart b/sky/framework/animation/animated_value.dart
similarity index 62%
rename from sky/framework/animation/animation.dart
rename to sky/framework/animation/animated_value.dart
index 62b93f676388819dabbb3c8079d9851942e010ff..faf17b6a82b901a7bc9e3d45253a3cfa0cf36cf6 100644
--- a/sky/framework/animation/animation.dart
+++ b/sky/framework/animation/animated_value.dart
@@ -2,11 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import '../fn.dart';
import 'curves.dart';
import 'dart:async';
import 'generators.dart';
-class Animation {
+class AnimatedValue {
+ StreamController _controller = new StreamController(sync: true);
+ AnimationGenerator _animation;
+ double _value;
+
+ AnimatedValue(double initial) {
+ value = initial;
+ }
+
Stream<double> get onValueChanged => _controller.stream;
double get value => _value;
@@ -18,12 +27,6 @@ class Animation {
bool get isAnimating => _animation != null;
- StreamController _controller = new StreamController(sync: true);
-
- AnimationGenerator _animation;
-
- double _value;
-
void _setValue(double value) {
_value = value;
_controller.add(_value);
@@ -52,3 +55,28 @@ class Animation {
});
}
}
+
+class AnimatedValueListener {
+ final Component _component;
+ final AnimatedValue _value;
+ StreamSubscription<double> _subscription;
+
+ AnimatedValueListener(this._component, this._value);
+
+ double get value => _value == null ? null : _value.value;
+
+ void ensureListening() {
+ if (_subscription != null || _value == null)
+ return;
+ _subscription = _value.onValueChanged.listen((_) {
+ _component.scheduleBuild();
+ });
+ }
+
+ void stopListening() {
+ if (_subscription == null)
+ return;
+ _subscription.cancel();
+ _subscription = null;
+ }
+}
« no previous file with comments | « sky/examples/stocks-fn/lib/stock_app.dart ('k') | sky/framework/animation/animation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698