| 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:math' as math; | 5 import 'dart:math' as math; |
| 6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
| 7 | 7 |
| 8 import 'package:sky/animation/animation_performance.dart'; | 8 import 'package:sky/animation/animation_performance.dart'; |
| 9 import 'package:sky/painting/box_painter.dart'; | 9 import 'package:sky/painting/box_painter.dart'; |
| 10 import 'package:sky/theme/colors.dart'; | 10 import 'package:sky/theme/colors.dart'; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 return 1.0; | 114 return 1.0; |
| 115 double unit = 1.0 / items.length; | 115 double unit = 1.0 / items.length; |
| 116 double duration = 1.5 * unit; | 116 double duration = 1.5 * unit; |
| 117 double start = i * unit; | 117 double start = i * unit; |
| 118 return math.max(0.0, math.min(1.0, (_position.value - start) / duration)); | 118 return math.max(0.0, math.min(1.0, (_position.value - start) / duration)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 Widget build() { | 121 Widget build() { |
| 122 int i = 0; | 122 int i = 0; |
| 123 List<Widget> children = new List.from(items.map((Widget item) { | 123 List<Widget> children = new List.from(items.map((Widget item) { |
| 124 double opacity = _opacityFor(i); | 124 return new Opacity(opacity: _opacityFor(i++), child: item); |
| 125 return new PopupMenuItem(child: item, opacity: opacity); | |
| 126 })); | 125 })); |
| 127 | 126 |
| 128 return new Opacity( | 127 return new Opacity( |
| 129 opacity: math.min(1.0, _position.value * 3.0), | 128 opacity: math.min(1.0, _position.value * 3.0), |
| 130 child: new Container( | 129 child: new Container( |
| 131 margin: new EdgeDims.all(_kMenuMargin), | 130 margin: new EdgeDims.all(_kMenuMargin), |
| 132 child: new CustomPaint( | 131 child: new CustomPaint( |
| 133 callback: (sky.Canvas canvas, Size size) { | 132 callback: (sky.Canvas canvas, Size size) { |
| 134 double width = math.min(size.width, size.width * (0.5 + _position.va
lue * 2.0)); | 133 double width = math.min(size.width, size.width * (0.5 + _position.va
lue * 2.0)); |
| 135 double height = math.min(size.height, size.height * _position.value
* 1.5); | 134 double height = math.min(size.height, size.height * _position.value
* 1.5); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 152 ) | 151 ) |
| 153 ) | 152 ) |
| 154 ) | 153 ) |
| 155 ) | 154 ) |
| 156 ) | 155 ) |
| 157 ) | 156 ) |
| 158 ); | 157 ); |
| 159 } | 158 } |
| 160 | 159 |
| 161 } | 160 } |
| OLD | NEW |