| 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'; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 static final Style _contentStyle = new Style(''' | 96 static final Style _contentStyle = new Style(''' |
| 97 background-color: ${Grey[50]}; | 97 background-color: ${Grey[50]}; |
| 98 will-change: transform; | 98 will-change: transform; |
| 99 position: absolute; | 99 position: absolute; |
| 100 width: ${_kWidth}px; | 100 width: ${_kWidth}px; |
| 101 top: 0; | 101 top: 0; |
| 102 left: 0; | 102 left: 0; |
| 103 bottom: 0;''' | 103 bottom: 0;''' |
| 104 ); | 104 ); |
| 105 | 105 |
| 106 List<Node> children; | 106 List<UINode> children; |
| 107 int level; | 107 int level; |
| 108 DrawerController controller; | 108 DrawerController controller; |
| 109 | 109 |
| 110 double _position; | 110 double _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 animateField(controller.position, #_position); | 118 animateField(controller.position, #_position); |
| 119 } | 119 } |
| 120 | 120 |
| 121 Node build() { | 121 UINode build() { |
| 122 bool isClosed = _position <= -_kWidth; | 122 bool isClosed = _position <= -_kWidth; |
| 123 String inlineStyle = 'display: ${isClosed ? 'none' : ''}'; | 123 String inlineStyle = 'display: ${isClosed ? 'none' : ''}'; |
| 124 String maskInlineStyle = 'opacity: ${(_position / _kWidth + 1) * 0.5}'; | 124 String maskInlineStyle = 'opacity: ${(_position / _kWidth + 1) * 0.5}'; |
| 125 String contentInlineStyle = 'transform: translateX(${_position}px)'; | 125 String contentInlineStyle = 'transform: translateX(${_position}px)'; |
| 126 | 126 |
| 127 var mask = new EventTarget( | 127 var mask = new EventListenerNode( |
| 128 new Container( | 128 new Container( |
| 129 style: _maskStyle, | 129 style: _maskStyle, |
| 130 inlineStyle: maskInlineStyle | 130 inlineStyle: maskInlineStyle |
| 131 ), | 131 ), |
| 132 onGestureTap: controller.handleMaskTap, | 132 onGestureTap: controller.handleMaskTap, |
| 133 onGestureFlingStart: controller.handleFlingStart | 133 onGestureFlingStart: controller.handleFlingStart |
| 134 ); | 134 ); |
| 135 | 135 |
| 136 Material content = new Material( | 136 Material content = new Material( |
| 137 content: new Container( | 137 content: new Container( |
| 138 style: _contentStyle, | 138 style: _contentStyle, |
| 139 inlineStyle: contentInlineStyle, | 139 inlineStyle: contentInlineStyle, |
| 140 children: children | 140 children: children |
| 141 ), | 141 ), |
| 142 level: level); | 142 level: level); |
| 143 | 143 |
| 144 return new EventTarget( | 144 return new EventListenerNode( |
| 145 new Container( | 145 new Container( |
| 146 style: _style, | 146 style: _style, |
| 147 inlineStyle: inlineStyle, | 147 inlineStyle: inlineStyle, |
| 148 children: [ mask, content ] | 148 children: [ mask, content ] |
| 149 ), | 149 ), |
| 150 onPointerDown: controller.handlePointerDown, | 150 onPointerDown: controller.handlePointerDown, |
| 151 onPointerMove: controller.handlePointerMove, | 151 onPointerMove: controller.handlePointerMove, |
| 152 onPointerUp: controller.handlePointerUp, | 152 onPointerUp: controller.handlePointerUp, |
| 153 onPointerCancel: controller.handlePointerCancel | 153 onPointerCancel: controller.handlePointerCancel |
| 154 ); | 154 ); |
| 155 } | 155 } |
| 156 } | 156 } |
| OLD | NEW |