| 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 'animated_component.dart'; | 5 import 'animated_component.dart'; |
| 6 import '../animation/animated_value.dart'; | 6 import '../animation/animated_value.dart'; |
| 7 import '../fn.dart'; | 7 import '../fn.dart'; |
| 8 import '../theme/colors.dart'; | 8 import '../theme/colors.dart'; |
| 9 import '../theme/view-configuration.dart'; | 9 import '../theme/view-configuration.dart'; |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 class PopupMenu extends AnimatedComponent { | 37 class PopupMenu extends AnimatedComponent { |
| 38 static final Style _style = new Style(''' | 38 static final Style _style = new Style(''' |
| 39 border-radius: 2px; | 39 border-radius: 2px; |
| 40 padding: 8px 0; | 40 padding: 8px 0; |
| 41 box-sizing: border-box; | 41 box-sizing: border-box; |
| 42 background-color: ${Grey[50]};'''); | 42 background-color: ${Grey[50]};'''); |
| 43 | 43 |
| 44 List<List<Node>> items; | 44 List<List<UINode>> items; |
| 45 int level; | 45 int level; |
| 46 PopupMenuController controller; | 46 PopupMenuController controller; |
| 47 | 47 |
| 48 double _position; | 48 double _position; |
| 49 int _width; | 49 int _width; |
| 50 int _height; | 50 int _height; |
| 51 | 51 |
| 52 PopupMenu({ Object key, this.controller, this.items, this.level }) | 52 PopupMenu({ Object key, this.controller, this.items, this.level }) |
| 53 : super(key: key) { | 53 : super(key: key) { |
| 54 animateField(controller.position, #_position); | 54 animateField(controller.position, #_position); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 75 } | 75 } |
| 76 | 76 |
| 77 void _measureSize() { | 77 void _measureSize() { |
| 78 setState(() { | 78 setState(() { |
| 79 var root = getRoot(); | 79 var root = getRoot(); |
| 80 _width = root.clientWidth; | 80 _width = root.clientWidth; |
| 81 _height = root.clientHeight; | 81 _height = root.clientHeight; |
| 82 }); | 82 }); |
| 83 } | 83 } |
| 84 | 84 |
| 85 Node build() { | 85 UINode build() { |
| 86 int i = 0; | 86 int i = 0; |
| 87 List<Node> children = new List.from(items.map((List<Node> item) { | 87 List<UINode> children = new List.from(items.map((List<UINode> item) { |
| 88 double opacity = _opacityFor(i); | 88 double opacity = _opacityFor(i); |
| 89 return new PopupMenuItem(key: i++, children: item, opacity: opacity); | 89 return new PopupMenuItem(key: i++, children: item, opacity: opacity); |
| 90 })); | 90 })); |
| 91 | 91 |
| 92 return new Material( | 92 return new Material( |
| 93 content: new Container( | 93 content: new Container( |
| 94 style: _style, | 94 style: _style, |
| 95 inlineStyle: _inlineStyle(), | 95 inlineStyle: _inlineStyle(), |
| 96 children: children | 96 children: children |
| 97 ), | 97 ), |
| 98 level: level); | 98 level: level); |
| 99 } | 99 } |
| 100 } | 100 } |
| OLD | NEW |