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

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

Issue 1172173002: Clean up a bunch of our Dart code. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: upstream merge 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 '../animation/curves.dart'; 6 import '../animation/curves.dart';
7 import '../fn2.dart'; 7 import '../fn2.dart';
8 import '../theme2/colors.dart'; 8 import '../theme2/colors.dart';
9 import '../theme2/shadows.dart'; 9 import '../theme2/shadows.dart';
10 import 'animated_component.dart'; 10 import 'animated_component.dart';
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 if (velocityX < _kMinFlingVelocity) 82 if (velocityX < _kMinFlingVelocity)
83 return; 83 return;
84 84
85 double targetPosition = direction < 0.0 ? -_kWidth : 0.0; 85 double targetPosition = direction < 0.0 ? -_kWidth : 0.0;
86 double distance = (targetPosition - position.value).abs(); 86 double distance = (targetPosition - position.value).abs();
87 double duration = distance / velocityX; 87 double duration = distance / velocityX;
88 88
89 if (distance > 0) 89 if (distance > 0)
90 position.animateTo(targetPosition, duration, curve: linear); 90 position.animateTo(targetPosition, duration, curve: linear);
91 } 91 }
92
92 } 93 }
93 94
94 class Drawer extends AnimatedComponent { 95 class Drawer extends AnimatedComponent {
95 List<UINode> children;
96 int level;
97 DrawerController controller;
98
99 double _position;
100 96
101 Drawer({ 97 Drawer({
102 Object key, 98 Object key,
103 this.controller, 99 this.controller,
104 this.children, 100 this.children,
105 this.level: 0 101 this.level: 0
106 }) : super(key: key) { 102 }) : super(key: key) {
107 animate(controller.position, (double value) { 103 animate(controller.position, (double value) {
108 _position = value; 104 _position = value;
109 }); 105 });
110 } 106 }
111 107
108 List<UINode> children;
109 int level;
110 DrawerController controller;
111
112 double _position;
113
112 UINode build() { 114 UINode build() {
113 Matrix4 transform = new Matrix4.identity(); 115 Matrix4 transform = new Matrix4.identity();
114 transform.translate(_position); 116 transform.translate(_position);
115 117
116 double scaler = _position / _kWidth + 1; 118 double scaler = _position / _kWidth + 1;
117 Color maskColor = new Color.fromARGB((0x7F * scaler).floor(), 0, 0, 0); 119 Color maskColor = new Color.fromARGB((0x7F * scaler).floor(), 0, 0, 0);
118 120
119 var mask = new EventListenerNode( 121 var mask = new EventListenerNode(
120 new Container(decoration: new BoxDecoration(backgroundColor: maskColor)), 122 new Container(decoration: new BoxDecoration(backgroundColor: maskColor)),
121 onGestureTap: controller.handleMaskTap, 123 onGestureTap: controller.handleMaskTap,
(...skipping 12 matching lines...) Expand all
134 return new EventListenerNode( 136 return new EventListenerNode(
135 new StackContainer( 137 new StackContainer(
136 children: [ mask, content ] 138 children: [ mask, content ]
137 ), 139 ),
138 onPointerDown: controller.handlePointerDown, 140 onPointerDown: controller.handlePointerDown,
139 onPointerMove: controller.handlePointerMove, 141 onPointerMove: controller.handlePointerMove,
140 onPointerUp: controller.handlePointerUp, 142 onPointerUp: controller.handlePointerUp,
141 onPointerCancel: controller.handlePointerCancel 143 onPointerCancel: controller.handlePointerCancel
142 ); 144 );
143 } 145 }
146
144 } 147 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/components2/checkbox.dart ('k') | sky/sdk/lib/framework/components2/drawer_header.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698