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 '../fn.dart'; | 5 import '../fn.dart'; |
6 import '../theme/colors.dart'; | 6 import '../theme/colors.dart'; |
7 import 'material.dart'; | 7 import 'material.dart'; |
| 8 import 'popup_menu_item.dart'; |
8 | 9 |
9 class PopupMenu extends Component { | 10 class PopupMenu extends Component { |
10 static final Style _style = new Style(''' | 11 static final Style _style = new Style(''' |
11 border-radius: 2px; | 12 border-radius: 2px; |
| 13 padding: 8px 0; |
12 background-color: ${Grey[50]};''' | 14 background-color: ${Grey[50]};''' |
13 ); | 15 ); |
14 | 16 |
15 List<Node> children; | 17 List<List<Node>> items; |
16 int level; | 18 int level; |
17 | 19 |
18 PopupMenu({ Object key, this.children, this.level }) : super(key: key); | 20 PopupMenu({ Object key, this.items, this.level }) : super(key: key); |
19 | 21 |
20 Node build() { | 22 Node build() { |
| 23 List<Node> children = []; |
| 24 int i = 0; |
| 25 items.forEach((List<Node> item) { |
| 26 children.add(new PopupMenuItem(key: i++, children: item)); |
| 27 }); |
| 28 |
21 return new Material( | 29 return new Material( |
22 style: _style, | 30 style: _style, |
23 children: children, | 31 children: children, |
24 level: level | 32 level: level |
25 ); | 33 ); |
26 } | 34 } |
27 } | 35 } |
OLD | NEW |