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

Side by Side Diff: sky/sdk/lib/widgets/drawer.dart

Issue 1226263003: Break dependency of AnimationPerformance on AnimatedValue (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: remove unused import Created 5 years, 5 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
« no previous file with comments | « sky/sdk/lib/widgets/animated_component.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 'dart:sky' as sky; 5 import 'dart:sky' as sky;
6 6
7 import '../animation/animation_performance.dart'; 7 import '../animation/animation_performance.dart';
8 import '../animation/curves.dart'; 8 import '../animation/curves.dart';
9 import '../theme/shadows.dart'; 9 import '../theme/shadows.dart';
10 import 'animated_component.dart'; 10 import 'animated_component.dart';
(...skipping 20 matching lines...) Expand all
31 // the user's finger. Odeon remedies this by attaching spring forces to the 31 // the user's finger. Odeon remedies this by attaching spring forces to the
32 // initial timeline when animating (so it doesn't look linear). 32 // initial timeline when animating (so it doesn't look linear).
33 const Curve _kAnimationCurve = linear; 33 const Curve _kAnimationCurve = linear;
34 34
35 typedef void DrawerStatusChangeHandler (bool showing); 35 typedef void DrawerStatusChangeHandler (bool showing);
36 36
37 class DrawerController { 37 class DrawerController {
38 DrawerController(this.onStatusChange) { 38 DrawerController(this.onStatusChange) {
39 performance = new AnimationPerformance() 39 performance = new AnimationPerformance()
40 ..duration = new Duration(milliseconds: _kBaseSettleDurationMS) 40 ..duration = new Duration(milliseconds: _kBaseSettleDurationMS)
41 ..variable = position; 41 ..variable = position
42 performance.timeline.onValueChanged.listen(_checkValue); 42 ..addListener(_checkValue);
43 } 43 }
44 final DrawerStatusChangeHandler onStatusChange; 44 final DrawerStatusChangeHandler onStatusChange;
45 45
46 AnimationPerformance performance; 46 AnimationPerformance performance;
47 final AnimatedPosition position = new AnimatedPosition( 47 final AnimatedPosition position = new AnimatedPosition(
48 new Point(-_kWidth, 0.0), Point.origin, curve: _kAnimationCurve); 48 new Point(-_kWidth, 0.0), Point.origin, curve: _kAnimationCurve);
49 49
50 bool _oldClosedState = true; 50 bool _oldClosedState = true;
51 void _checkValue(_) { 51 void _checkValue() {
52 var newClosedState = isClosed; 52 var newClosedState = isClosed;
53 if (onStatusChange != null && _oldClosedState != newClosedState) { 53 if (onStatusChange != null && _oldClosedState != newClosedState) {
54 onStatusChange(!newClosedState); 54 onStatusChange(!newClosedState);
55 _oldClosedState = newClosedState; 55 _oldClosedState = newClosedState;
56 } 56 }
57 } 57 }
58 58
59 bool get isClosed => performance.isDismissed; 59 bool get isClosed => performance.isDismissed;
60 bool get _isMostlyClosed => position.value.x <= -_kWidth/2; 60 bool get _isMostlyClosed => position.value.x <= -_kWidth/2;
61 61
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 } 95 }
96 96
97 class Drawer extends AnimatedComponent { 97 class Drawer extends AnimatedComponent {
98 Drawer({ 98 Drawer({
99 String key, 99 String key,
100 this.controller, 100 this.controller,
101 this.children, 101 this.children,
102 this.level: 0 102 this.level: 0
103 }) : super(key: key) { 103 }) : super(key: key) {
104 watch(controller.performance.timeline); 104 watchPerformance(controller.performance);
105 } 105 }
106 106
107 List<Widget> children; 107 List<Widget> children;
108 int level; 108 int level;
109 DrawerController controller; 109 DrawerController controller;
110 110
111 void syncFields(Drawer source) { 111 void syncFields(Drawer source) {
112 children = source.children; 112 children = source.children;
113 level = source.level; 113 level = source.level;
114 controller = source.controller; 114 controller = source.controller;
(...skipping 26 matching lines...) Expand all
141 child: new Stack([ mask, content ]), 141 child: new Stack([ mask, content ]),
142 onPointerDown: controller.handlePointerDown, 142 onPointerDown: controller.handlePointerDown,
143 onPointerMove: controller.handlePointerMove, 143 onPointerMove: controller.handlePointerMove,
144 onPointerUp: controller.handlePointerUp, 144 onPointerUp: controller.handlePointerUp,
145 onPointerCancel: controller.handlePointerCancel, 145 onPointerCancel: controller.handlePointerCancel,
146 onGestureFlingStart: controller.handleFlingStart 146 onGestureFlingStart: controller.handleFlingStart
147 ); 147 );
148 } 148 }
149 149
150 } 150 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/animated_component.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698