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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 _closeState = null; | 44 _closeState = null; |
45 result.complete(); | 45 result.complete(); |
46 return result.future; | 46 return result.future; |
47 } | 47 } |
48 assert(_closeState != null); | 48 assert(_closeState != null); |
49 return _closeState; | 49 return _closeState; |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 class PopupMenu extends AnimatedComponent { | 53 class PopupMenu extends AnimatedComponent { |
54 List<List<UINode>> items; | |
55 int level; | |
56 PopupMenuController controller; | |
57 | |
58 double _position; | |
59 // int _width; | |
60 // int _height; | |
61 | 54 |
62 PopupMenu({ Object key, this.controller, this.items, this.level }) | 55 PopupMenu({ Object key, this.controller, this.items, this.level }) |
63 : super(key: key) { | 56 : super(key: key) { |
64 animate(controller.position, (double value) { | 57 animate(controller.position, (double value) { |
65 _position = value; | 58 _position = value; |
66 }); | 59 }); |
67 // onDidMount(_measureSize); | 60 // onDidMount(_measureSize); |
68 } | 61 } |
69 | 62 |
| 63 List<List<UINode>> items; |
| 64 int level; |
| 65 PopupMenuController controller; |
| 66 |
| 67 double _position; |
| 68 // int _width; |
| 69 // int _height; |
| 70 |
70 double _opacityFor(int i) { | 71 double _opacityFor(int i) { |
71 if (_position == null || _position == 1.0) | 72 if (_position == null || _position == 1.0) |
72 return null; | 73 return null; |
73 double unit = 1.0 / items.length; | 74 double unit = 1.0 / items.length; |
74 double duration = 1.5 * unit; | 75 double duration = 1.5 * unit; |
75 double start = i * unit; | 76 double start = i * unit; |
76 return math.max(0.0, math.min(1.0, (_position - start) / duration)); | 77 return math.max(0.0, math.min(1.0, (_position - start) / duration)); |
77 } | 78 } |
78 | 79 |
79 // String _inlineStyle() { | 80 // String _inlineStyle() { |
(...skipping 26 matching lines...) Expand all Loading... |
106 child: new Container( | 107 child: new Container( |
107 padding: const EdgeDims.all(8.0), | 108 padding: const EdgeDims.all(8.0), |
108 decoration: new BoxDecoration( | 109 decoration: new BoxDecoration( |
109 backgroundColor: Grey[50], | 110 backgroundColor: Grey[50], |
110 borderRadius: 2.0, | 111 borderRadius: 2.0, |
111 boxShadow: Shadow[level]), | 112 boxShadow: Shadow[level]), |
112 child: new BlockContainer(children: children) | 113 child: new BlockContainer(children: children) |
113 ) | 114 ) |
114 ); | 115 ); |
115 } | 116 } |
| 117 |
116 } | 118 } |
OLD | NEW |