Commit 1ef3f82e authored by Adam Barth's avatar Adam Barth

Drawer edge swipe convers entire screen

When I tightened up the layout constraints for the Drawer in the
Scaffold, I ended up making the edge swipe detector cover the entire
screen.  This patch fixes that issue by putting the gesture detector for
the edge swipe just around the container with the proper width. We now
use a global key to maintain the state across hierarchy changes.
parent fb66bf11
...@@ -152,57 +152,59 @@ class DrawerControllerState extends State<DrawerController> { ...@@ -152,57 +152,59 @@ class DrawerControllerState extends State<DrawerController> {
} }
final AnimatedColorValue _color = new AnimatedColorValue(Colors.transparent, end: Colors.black54); final AnimatedColorValue _color = new AnimatedColorValue(Colors.transparent, end: Colors.black54);
final GlobalKey _gestureDetectorKey = new GlobalKey();
Widget build(BuildContext context) { Widget build(BuildContext context) {
HitTestBehavior behavior;
Widget child;
if (_performance.status == PerformanceStatus.dismissed) { if (_performance.status == PerformanceStatus.dismissed) {
behavior = HitTestBehavior.translucent; return new Align(
child = new Align(
alignment: const FractionalOffset(0.0, 0.5), alignment: const FractionalOffset(0.0, 0.5),
widthFactor: 1.0, child: new GestureDetector(
child: new Container(width: _kEdgeDragWidth) key: _gestureDetectorKey,
onHorizontalDragUpdate: _move,
onHorizontalDragEnd: _settle,
behavior: HitTestBehavior.translucent,
child: new Container(width: _kEdgeDragWidth)
)
); );
} else { } else {
_performance.updateVariable(_color); _performance.updateVariable(_color);
child = new RepaintBoundary( return new GestureDetector(
child: new Stack(<Widget>[ key: _gestureDetectorKey,
new GestureDetector( onHorizontalDragUpdate: _move,
onTap: close, onHorizontalDragEnd: _settle,
child: new DecoratedBox( child: new RepaintBoundary(
decoration: new BoxDecoration( child: new Stack(<Widget>[
backgroundColor: _color.value new GestureDetector(
), onTap: close,
child: new Container() child: new DecoratedBox(
) decoration: new BoxDecoration(
), backgroundColor: _color.value
new Align( ),
alignment: const FractionalOffset(0.0, 0.5), child: new Container()
child: new Listener( )
onPointerDown: _handlePointerDown, ),
child: new Align( new Align(
alignment: const FractionalOffset(1.0, 0.5), alignment: const FractionalOffset(0.0, 0.5),
widthFactor: _performance.progress, child: new Listener(
child: new SizeObserver( onPointerDown: _handlePointerDown,
onSizeChanged: _handleSizeChanged, child: new Align(
child: new RepaintBoundary( alignment: const FractionalOffset(1.0, 0.5),
child: new Focus( widthFactor: _performance.progress,
key: new GlobalObjectKey(config.key), child: new SizeObserver(
child: config.child onSizeChanged: _handleSizeChanged,
child: new RepaintBoundary(
child: new Focus(
key: new GlobalObjectKey(config.key),
child: config.child
)
) )
) )
) )
) )
) )
) ])
]) )
); );
} }
return new GestureDetector(
onHorizontalDragUpdate: _move,
onHorizontalDragEnd: _settle,
behavior: behavior,
child: child
);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment