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 'animated_component.dart'; | 5 import 'animated_component.dart'; |
6 import '../animation/animated_value.dart'; | 6 import '../animation/animated_value.dart'; |
7 import '../animation/curves.dart'; | 7 import '../animation/curves.dart'; |
8 import '../fn.dart'; | 8 import '../fn.dart'; |
9 import '../theme/colors.dart'; | 9 import '../theme/colors.dart'; |
10 import '../theme/shadows.dart'; | 10 import '../theme/shadows.dart'; |
11 import 'dart:async'; | 11 import 'dart:async'; |
12 import 'dart:math' as math; | 12 import 'dart:math' as math; |
13 import 'dart:sky' as sky; | 13 import 'dart:sky' as sky; |
14 import 'material.dart'; | 14 import 'material.dart'; |
15 | 15 |
16 const double _kWidth = 304.0; | 16 const double _kWidth = 304.0; |
17 const double _kMinFlingVelocity = 0.4; | 17 const double _kMinFlingVelocity = 0.4; |
18 const double _kBaseSettleDurationMS = 246.0; | 18 const double _kBaseSettleDurationMS = 246.0; |
19 const double _kMaxSettleDurationMS = 600.0; | 19 const double _kMaxSettleDurationMS = 600.0; |
20 const Curve _kAnimationCurve = parabolicRise; | 20 const Curve _kAnimationCurve = parabolicRise; |
21 | 21 |
22 class DrawerController { | 22 class DrawerController { |
23 final AnimatedValue position = new AnimatedValue(-_kWidth); | 23 final AnimatedValue position = new AnimatedValue(-_kWidth); |
24 | 24 |
| 25 bool get isClosed => position.value == -_kWidth; |
| 26 |
25 bool get _isMostlyClosed => position.value <= -_kWidth / 2; | 27 bool get _isMostlyClosed => position.value <= -_kWidth / 2; |
26 | 28 |
27 void toggle(_) => _isMostlyClosed ? _open() : _close(); | 29 void toggle(_) => _isMostlyClosed ? _open() : _close(); |
28 | 30 |
29 void handleMaskTap(_) => _close(); | 31 void handleMaskTap(_) => _close(); |
30 | 32 |
31 void handlePointerDown(_) => position.stop(); | 33 void handlePointerDown(_) => position.stop(); |
32 | 34 |
33 void handlePointerMove(sky.PointerEvent event) { | 35 void handlePointerMove(sky.PointerEvent event) { |
34 if (position.isAnimating) | 36 if (position.isAnimating) |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 inlineStyle: inlineStyle, | 148 inlineStyle: inlineStyle, |
147 children: [ mask, content ] | 149 children: [ mask, content ] |
148 ), | 150 ), |
149 onPointerDown: controller.handlePointerDown, | 151 onPointerDown: controller.handlePointerDown, |
150 onPointerMove: controller.handlePointerMove, | 152 onPointerMove: controller.handlePointerMove, |
151 onPointerUp: controller.handlePointerUp, | 153 onPointerUp: controller.handlePointerUp, |
152 onPointerCancel: controller.handlePointerCancel | 154 onPointerCancel: controller.handlePointerCancel |
153 ); | 155 ); |
154 } | 156 } |
155 } | 157 } |
OLD | NEW |