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 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:math' as math; | 6 import 'dart:math' as math; |
7 import 'dart:sky' as sky; | 7 import 'dart:sky' as sky; |
8 | 8 |
9 import '../framework/animation/animated_value.dart'; | 9 import '../framework/animation/animated_value.dart'; |
10 import '../painting/box_painter.dart'; | 10 import '../painting/box_painter.dart'; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 double unit = 1.0 / items.length; | 87 double unit = 1.0 / items.length; |
88 double duration = 1.5 * unit; | 88 double duration = 1.5 * unit; |
89 double start = i * unit; | 89 double start = i * unit; |
90 return math.max(0.0, math.min(1.0, (_position - start) / duration)); | 90 return math.max(0.0, math.min(1.0, (_position - start) / duration)); |
91 } | 91 } |
92 | 92 |
93 Widget build() { | 93 Widget build() { |
94 int i = 0; | 94 int i = 0; |
95 List<Widget> children = new List.from(items.map((Widget item) { | 95 List<Widget> children = new List.from(items.map((Widget item) { |
96 double opacity = _opacityFor(i); | 96 double opacity = _opacityFor(i); |
97 return new PopupMenuItem(key: '${key}-${item.key}', | 97 return new PopupMenuItem(child: item, opacity: opacity); |
98 child: item, | |
99 opacity: opacity); | |
100 })); | 98 })); |
101 | 99 |
102 return new Opacity( | 100 return new Opacity( |
103 opacity: math.min(1.0, _position * 3.0), | 101 opacity: math.min(1.0, _position * 3.0), |
104 child: new ShrinkWrapWidth( | 102 child: new ShrinkWrapWidth( |
105 child: new CustomPaint( | 103 child: new CustomPaint( |
106 callback: (sky.Canvas canvas, Size size) { | 104 callback: (sky.Canvas canvas, Size size) { |
107 double width = math.min(size.width, size.width * (0.5 + _position *
2.0)); | 105 double width = math.min(size.width, size.width * (0.5 + _position *
2.0)); |
108 double height = math.min(size.height, size.height * _position * 1.5)
; | 106 double height = math.min(size.height, size.height * _position * 1.5)
; |
109 _painter.paint(canvas, new Rect.fromLTRB(size.width - width, 0.0, wi
dth, height)); | 107 _painter.paint(canvas, new Rect.fromLTRB(size.width - width, 0.0, wi
dth, height)); |
110 }, | 108 }, |
111 child: new Container( | 109 child: new Container( |
112 padding: const EdgeDims.all(8.0), | 110 padding: const EdgeDims.all(8.0), |
113 child: new Block(children) | 111 child: new Block(children) |
114 ) | 112 ) |
115 ) | 113 ) |
116 ) | 114 ) |
117 ); | 115 ); |
118 } | 116 } |
119 | 117 |
120 } | 118 } |
OLD | NEW |