Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: sky/sdk/lib/framework/components2/popup_menu.dart

Issue 1171273002: Move AnimatedComponent away from mirrors and towards a callback-based setter. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 List<List<UINode>> items; 54 List<List<UINode>> items;
55 int level; 55 int level;
56 PopupMenuController controller; 56 PopupMenuController controller;
57 57
58 double _position; 58 double _position;
59 // int _width; 59 // int _width;
60 // int _height; 60 // int _height;
61 61
62 PopupMenu({ Object key, this.controller, this.items, this.level }) 62 PopupMenu({ Object key, this.controller, this.items, this.level })
63 : super(key: key) { 63 : super(key: key) {
64 animateField(controller.position, #_position); 64 animate(controller.position, (double value) {
65 _position = value;
66 });
65 // onDidMount(_measureSize); 67 // onDidMount(_measureSize);
66 } 68 }
67 69
68 double _opacityFor(int i) { 70 double _opacityFor(int i) {
69 if (_position == null || _position == 1.0) 71 if (_position == null || _position == 1.0)
70 return null; 72 return null;
71 double unit = 1.0 / items.length; 73 double unit = 1.0 / items.length;
72 double duration = 1.5 * unit; 74 double duration = 1.5 * unit;
73 double start = i * unit; 75 double start = i * unit;
74 return math.max(0.0, math.min(1.0, (_position - start) / duration)); 76 return math.max(0.0, math.min(1.0, (_position - start) / duration));
(...skipping 30 matching lines...) Expand all
105 padding: const EdgeDims.all(8.0), 107 padding: const EdgeDims.all(8.0),
106 decoration: new BoxDecoration( 108 decoration: new BoxDecoration(
107 backgroundColor: Grey[50], 109 backgroundColor: Grey[50],
108 borderRadius: 2.0, 110 borderRadius: 2.0,
109 boxShadow: Shadow[level]), 111 boxShadow: Shadow[level]),
110 child: new BlockContainer(children: children) 112 child: new BlockContainer(children: children)
111 ) 113 )
112 ); 114 );
113 } 115 }
114 } 116 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/components2/drawer.dart ('k') | sky/sdk/lib/framework/rendering/paragraph.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698