| 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 '../animation/animated_value.dart'; | 5 import '../animation/animated_value.dart'; |
| 6 import '../fn2.dart'; | 6 import '../fn2.dart'; |
| 7 import '../theme2/colors.dart'; | 7 import '../theme2/colors.dart'; |
| 8 import '../theme2/shadows.dart'; | 8 import '../theme2/shadows.dart'; |
| 9 import 'animated_component.dart'; | 9 import 'animated_component.dart'; |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 class PopupMenu extends AnimatedComponent { | 53 class PopupMenu extends AnimatedComponent { |
| 54 | 54 |
| 55 PopupMenu({ Object key, this.controller, this.items, this.level }) | 55 PopupMenu({ Object key, this.controller, this.items, this.level }) |
| 56 : super(key: key) { | 56 : super(key: key) { |
| 57 animate(controller.position, (double value) { | 57 animate(controller.position, (double value) { |
| 58 _position = value; | 58 _position = value; |
| 59 }); | 59 }); |
| 60 // onDidMount(_measureSize); | |
| 61 } | 60 } |
| 62 | 61 |
| 63 PopupMenuController controller; | 62 PopupMenuController controller; |
| 64 List<List<UINode>> items; | 63 List<List<UINode>> items; |
| 65 int level; | 64 int level; |
| 66 | 65 |
| 67 void syncFields(PopupMenu source) { | 66 void syncFields(PopupMenu source) { |
| 68 controller = source.controller; | 67 controller = source.controller; |
| 69 items = source.items; | 68 items = source.items; |
| 70 level = source.level; | 69 level = source.level; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 87 // String _inlineStyle() { | 86 // String _inlineStyle() { |
| 88 // if (_position == null || _position == 1.0 || | 87 // if (_position == null || _position == 1.0 || |
| 89 // _height == null || _width == null) | 88 // _height == null || _width == null) |
| 90 // return null; | 89 // return null; |
| 91 // return ''' | 90 // return ''' |
| 92 // opacity: ${math.min(1.0, _position * 3.0)}; | 91 // opacity: ${math.min(1.0, _position * 3.0)}; |
| 93 // width: ${math.min(_width, _width * (0.5 + _position * 2.0))}px; | 92 // width: ${math.min(_width, _width * (0.5 + _position * 2.0))}px; |
| 94 // height: ${math.min(_height, _height * _position * 1.5)}px;'''; | 93 // height: ${math.min(_height, _height * _position * 1.5)}px;'''; |
| 95 // } | 94 // } |
| 96 | 95 |
| 96 // void didMount() { |
| 97 // _measureSize(); |
| 98 // super.didMount(); |
| 99 // } |
| 100 |
| 97 // void _measureSize() { | 101 // void _measureSize() { |
| 98 // setState(() { | 102 // setState(() { |
| 99 // var root = getRoot(); | 103 // var root = getRoot(); |
| 100 // _width = root.width.round(); | 104 // _width = root.width.round(); |
| 101 // _height = root.height.round(); | 105 // _height = root.height.round(); |
| 102 // }); | 106 // }); |
| 103 // } | 107 // } |
| 104 | 108 |
| 105 UINode build() { | 109 UINode build() { |
| 106 int i = 0; | 110 int i = 0; |
| 107 List<UINode> children = new List.from(items.map((List<UINode> item) { | 111 List<UINode> children = new List.from(items.map((List<UINode> item) { |
| 108 double opacity = _opacityFor(i); | 112 double opacity = _opacityFor(i); |
| 109 return new PopupMenuItem(key: i++, children: item, opacity: opacity); | 113 return new PopupMenuItem(key: i++, children: item, opacity: opacity); |
| 110 })); | 114 })); |
| 111 | 115 |
| 112 // inlineStyle: _inlineStyle(), | 116 // inlineStyle: _inlineStyle(), |
| 113 return new ShrinkWrapWidth( | 117 return new ShrinkWrapWidth( |
| 114 child: new Container( | 118 child: new Container( |
| 115 padding: const EdgeDims.all(8.0), | 119 padding: const EdgeDims.all(8.0), |
| 116 decoration: new BoxDecoration( | 120 decoration: new BoxDecoration( |
| 117 backgroundColor: Grey[50], | 121 backgroundColor: Grey[50], |
| 118 borderRadius: 2.0, | 122 borderRadius: 2.0, |
| 119 boxShadow: Shadow[level]), | 123 boxShadow: Shadow[level]), |
| 120 child: new BlockContainer(children: children) | 124 child: new BlockContainer(children: children) |
| 121 ) | 125 ) |
| 122 ); | 126 ); |
| 123 } | 127 } |
| 124 | 128 |
| 125 } | 129 } |
| OLD | NEW |