From 1ef3f82e0f39693866d8d2c2059c0e952cfa9736 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Fri, 8 Jan 2016 19:40:04 -0800 Subject: [PATCH] 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. --- packages/flutter/lib/src/material/drawer.dart | 78 ++++++++++--------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/packages/flutter/lib/src/material/drawer.dart b/packages/flutter/lib/src/material/drawer.dart index f85db0fe3d..0b16e3d7f6 100644 --- a/packages/flutter/lib/src/material/drawer.dart +++ b/packages/flutter/lib/src/material/drawer.dart @@ -152,57 +152,59 @@ class DrawerControllerState extends State { } final AnimatedColorValue _color = new AnimatedColorValue(Colors.transparent, end: Colors.black54); + final GlobalKey _gestureDetectorKey = new GlobalKey(); Widget build(BuildContext context) { - HitTestBehavior behavior; - Widget child; if (_performance.status == PerformanceStatus.dismissed) { - behavior = HitTestBehavior.translucent; - child = new Align( + return new Align( alignment: const FractionalOffset(0.0, 0.5), - widthFactor: 1.0, - child: new Container(width: _kEdgeDragWidth) + child: new GestureDetector( + key: _gestureDetectorKey, + onHorizontalDragUpdate: _move, + onHorizontalDragEnd: _settle, + behavior: HitTestBehavior.translucent, + child: new Container(width: _kEdgeDragWidth) + ) ); } else { _performance.updateVariable(_color); - child = new RepaintBoundary( - child: new Stack([ - new GestureDetector( - onTap: close, - child: new DecoratedBox( - decoration: new BoxDecoration( - backgroundColor: _color.value - ), - child: new Container() - ) - ), - new Align( - alignment: const FractionalOffset(0.0, 0.5), - child: new Listener( - onPointerDown: _handlePointerDown, - child: new Align( - alignment: const FractionalOffset(1.0, 0.5), - widthFactor: _performance.progress, - child: new SizeObserver( - onSizeChanged: _handleSizeChanged, - child: new RepaintBoundary( - child: new Focus( - key: new GlobalObjectKey(config.key), - child: config.child + return new GestureDetector( + key: _gestureDetectorKey, + onHorizontalDragUpdate: _move, + onHorizontalDragEnd: _settle, + child: new RepaintBoundary( + child: new Stack([ + new GestureDetector( + onTap: close, + child: new DecoratedBox( + decoration: new BoxDecoration( + backgroundColor: _color.value + ), + child: new Container() + ) + ), + new Align( + alignment: const FractionalOffset(0.0, 0.5), + child: new Listener( + onPointerDown: _handlePointerDown, + child: new Align( + alignment: const FractionalOffset(1.0, 0.5), + widthFactor: _performance.progress, + child: new SizeObserver( + 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 - ); } }