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

Unified Diff: sky/framework/components/popup_menu.dart

Issue 1027633003: [Effen] Add AnimatedComponent base class (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: cr changes 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/framework/components/input.dart ('k') | sky/framework/components/popup_menu_item.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/components/popup_menu.dart
diff --git a/sky/framework/components/popup_menu.dart b/sky/framework/components/popup_menu.dart
index b69a50d340a4068513107ca0ae45e143d7bae925..ea736016b0571a658f2d32972f5f87dd3c8f3fe7 100644
--- a/sky/framework/components/popup_menu.dart
+++ b/sky/framework/components/popup_menu.dart
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'animated_component.dart';
import '../animation/animated_value.dart';
import '../fn.dart';
import '../theme/colors.dart';
@@ -32,7 +33,7 @@ class PopupMenuController {
}
}
-class PopupMenu extends Component {
+class PopupMenu extends AnimatedComponent {
static final Style _style = new Style('''
border-radius: 2px;
padding: 8px 0;
@@ -43,14 +44,16 @@ class PopupMenu extends Component {
int level;
PopupMenuController controller;
- AnimatedValueListener _position;
+ double _position;
List<AnimatedValue> _opacities;
int _width;
int _height;
PopupMenu({ Object key, this.controller, this.items, this.level })
: super(key: key) {
- _position = new AnimatedValueListener(this, controller.position);
+ animateField(controller.position, #_position);
+
+ onDidMount(_measureSize);
}
void _ensureItemAnimations() {
@@ -65,16 +68,15 @@ class PopupMenu extends Component {
}
String _inlineStyle() {
- double value = _position.value;
- if (value == null || value == 1.0 || _height == null || _width == null)
+ if (_position == null || _position == 1.0 || _height == null || _width == null)
return null;
return '''
- opacity: ${math.min(1.0, value * 1.5)};
- width: ${math.min(_width, _width * value * 3.0)}px;
- height: ${_height * value}px;''';
+ opacity: ${math.min(1.0, _position * 1.5)};
+ width: ${math.min(_width, _width * _position * 3.0)}px;
+ height: ${_height * _position}px;''';
}
- void didMount() {
+ void _measureSize() {
setState(() {
var root = getRoot();
_width = root.clientWidth;
@@ -82,12 +84,7 @@ class PopupMenu extends Component {
});
}
- void didUnmount() {
- _position.stopListening();
- }
-
Node build() {
- _position.ensureListening();
_ensureItemAnimations();
List<Node> children = [];
« no previous file with comments | « sky/framework/components/input.dart ('k') | sky/framework/components/popup_menu_item.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698