| 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 'dart:math' as math; | 5 import 'dart:math' as math; |
| 6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
| 7 | 7 |
| 8 import 'package:vector_math/vector_math.dart'; | 8 import 'package:vector_math/vector_math.dart'; |
| 9 | 9 |
| 10 import '../animation/animated_value.dart'; | 10 import '../animation/animated_value.dart'; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 | 108 |
| 109 class Drawer extends AnimatedComponent { | 109 class Drawer extends AnimatedComponent { |
| 110 | 110 |
| 111 Drawer({ | 111 Drawer({ |
| 112 String key, | 112 String key, |
| 113 this.controller, | 113 this.controller, |
| 114 this.children, | 114 this.children, |
| 115 this.level: 0 | 115 this.level: 0 |
| 116 }) : super(key: key) { | 116 }) : super(key: key) { |
| 117 animate(controller.position, (double value) { | 117 watch(controller.position); |
| 118 _position = value; | |
| 119 }); | |
| 120 } | 118 } |
| 121 | 119 |
| 122 List<Widget> children; | 120 List<Widget> children; |
| 123 int level; | 121 int level; |
| 124 DrawerController controller; | 122 DrawerController controller; |
| 125 | 123 |
| 126 void syncFields(Drawer source) { | 124 void syncFields(Drawer source) { |
| 127 children = source.children; | 125 children = source.children; |
| 128 level = source.level; | 126 level = source.level; |
| 129 controller = source.controller; | 127 controller = source.controller; |
| 130 super.syncFields(source); | 128 super.syncFields(source); |
| 131 } | 129 } |
| 132 | 130 |
| 133 double _position; | |
| 134 | |
| 135 Widget build() { | 131 Widget build() { |
| 136 Matrix4 transform = new Matrix4.identity(); | 132 Matrix4 transform = new Matrix4.identity(); |
| 137 transform.translate(_position); | 133 transform.translate(controller.position.value); |
| 138 | 134 |
| 139 double scaler = _position / _kWidth + 1; | 135 double scaler = controller.position.value / _kWidth + 1; |
| 140 Color maskColor = new Color.fromARGB((0x7F * scaler).floor(), 0, 0, 0); | 136 Color maskColor = new Color.fromARGB((0x7F * scaler).floor(), 0, 0, 0); |
| 141 | 137 |
| 142 var mask = new Listener( | 138 var mask = new Listener( |
| 143 child: new Container(decoration: new BoxDecoration(backgroundColor: maskCo
lor)), | 139 child: new Container(decoration: new BoxDecoration(backgroundColor: maskCo
lor)), |
| 144 onGestureTap: controller.handleMaskTap, | 140 onGestureTap: controller.handleMaskTap, |
| 145 onGestureFlingStart: controller.handleFlingStart | 141 onGestureFlingStart: controller.handleFlingStart |
| 146 ); | 142 ); |
| 147 | 143 |
| 148 Container content = new Container( | 144 Container content = new Container( |
| 149 decoration: new BoxDecoration( | 145 decoration: new BoxDecoration( |
| 150 backgroundColor: Grey[50], | 146 backgroundColor: Grey[50], |
| 151 boxShadow: shadows[level]), | 147 boxShadow: shadows[level]), |
| 152 width: _kWidth, | 148 width: _kWidth, |
| 153 transform: transform, | 149 transform: transform, |
| 154 child: new Block(children) | 150 child: new Block(children) |
| 155 ); | 151 ); |
| 156 | 152 |
| 157 return new Listener( | 153 return new Listener( |
| 158 child: new Stack([ mask, content ]), | 154 child: new Stack([ mask, content ]), |
| 159 onPointerDown: controller.handlePointerDown, | 155 onPointerDown: controller.handlePointerDown, |
| 160 onPointerMove: controller.handlePointerMove, | 156 onPointerMove: controller.handlePointerMove, |
| 161 onPointerUp: controller.handlePointerUp, | 157 onPointerUp: controller.handlePointerUp, |
| 162 onPointerCancel: controller.handlePointerCancel | 158 onPointerCancel: controller.handlePointerCancel |
| 163 ); | 159 ); |
| 164 } | 160 } |
| 165 | 161 |
| 166 } | 162 } |
| OLD | NEW |