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 '../animation/animated_value.dart'; | 5 import '../animation/animated_value.dart'; |
6 import '../animation/curves.dart'; | 6 import '../animation/curves.dart'; |
7 import '../fn.dart'; | 7 import '../fn.dart'; |
8 import '../theme/colors.dart'; | 8 import '../theme/colors.dart'; |
9 import '../theme/shadows.dart'; | 9 import '../theme/shadows.dart'; |
10 import 'dart:async'; | 10 import 'dart:async'; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 DrawerController controller; | 108 DrawerController controller; |
109 | 109 |
110 AnimatedValueListener _position; | 110 AnimatedValueListener _position; |
111 | 111 |
112 Drawer({ | 112 Drawer({ |
113 Object key, | 113 Object key, |
114 this.controller, | 114 this.controller, |
115 this.children, | 115 this.children, |
116 this.level: 0 | 116 this.level: 0 |
117 }) : super(key: key) { | 117 }) : super(key: key) { |
118 events.listen('pointerdown', controller.handlePointerDown); | |
119 events.listen('pointermove', controller.handlePointerMove); | |
120 events.listen('pointerup', controller.handlePointerUp); | |
121 events.listen('pointercancel', controller.handlePointerCancel); | |
122 _position = new AnimatedValueListener(this, controller.position); | 118 _position = new AnimatedValueListener(this, controller.position); |
123 } | 119 } |
124 | 120 |
125 void didUnmount() { | 121 void didUnmount() { |
126 _position.stopListening(); | 122 _position.stopListening(); |
127 } | 123 } |
128 | 124 |
129 Node build() { | 125 Node build() { |
130 _position.ensureListening(); | 126 _position.ensureListening(); |
131 | 127 |
132 bool isClosed = _position.value <= -_kWidth; | 128 bool isClosed = _position.value <= -_kWidth; |
133 String inlineStyle = 'display: ${isClosed ? 'none' : ''}'; | 129 String inlineStyle = 'display: ${isClosed ? 'none' : ''}'; |
134 String maskInlineStyle = 'opacity: ${(_position.value / _kWidth + 1) * 0.5}'
; | 130 String maskInlineStyle = 'opacity: ${(_position.value / _kWidth + 1) * 0.5}'
; |
135 String contentInlineStyle = 'transform: translateX(${_position.value}px)'; | 131 String contentInlineStyle = 'transform: translateX(${_position.value}px)'; |
136 | 132 |
137 Container mask = new Container( | 133 var mask = new EventTarget( |
138 key: 'Mask', | 134 new Container( |
139 style: _maskStyle, | 135 key: 'Mask', |
140 inlineStyle: maskInlineStyle | 136 style: _maskStyle, |
141 )..events.listen('gesturetap', controller.handleMaskTap) | 137 inlineStyle: maskInlineStyle |
142 ..events.listen('gestureflingstart', controller.handleFlingStart); | 138 ), |
| 139 onGestureTap: controller.handleMaskTap, |
| 140 onGestureFlingStart: controller.handleFlingStart |
| 141 ); |
143 | 142 |
144 Material content = new Material( | 143 Material content = new Material( |
145 key: 'Content', | 144 key: 'Content', |
146 style: _contentStyle, | 145 style: _contentStyle, |
147 inlineStyle: contentInlineStyle, | 146 inlineStyle: contentInlineStyle, |
148 children: children, | 147 children: children, |
149 level: level | 148 level: level |
150 ); | 149 ); |
151 | 150 |
152 return new Container( | 151 return new EventTarget( |
153 style: _style, | 152 new Container( |
154 inlineStyle: inlineStyle, | 153 style: _style, |
155 children: [ mask, content ] | 154 inlineStyle: inlineStyle, |
| 155 children: [ mask, content ] |
| 156 ), |
| 157 onPointerDown: controller.handlePointerDown, |
| 158 onPointerMove: controller.handlePointerMove, |
| 159 onPointerUp: controller.handlePointerUp, |
| 160 onPointerCancel: controller.handlePointerCancel |
156 ); | 161 ); |
157 } | 162 } |
158 } | 163 } |
OLD | NEW |