New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvement: Slide back menu when opened #11
Comments
I updated your ZoomDrawer widget and modified the build method to get gestures callbacks on all the stack, not only the menu. @override
Widget build(BuildContext context) {
final slidePercent =
CHZoomDrawer.isRTL() ? MediaQuery.of(context).size.width * .1 : 15.0;
return GestureDetector(
onPanUpdate: (details) {
print(details);
if (details.delta.dx < -6 && !_rtl || details.delta.dx < 6 && _rtl) {
toggle();
}
},
child: Stack(
children: [
widget.menuScreen,
if (widget.showShadow) ...[
/// Displaying the first shadow
AnimatedBuilder(
animation: _animationController,
builder: (_, w) => _zoomAndSlideContent(w,
angle: (widget.angle == 0.0) ? 0.0 : widget.angle - 8,
scale: .9,
slide: slidePercent * 2),
child: Container(
color: widget.backgroundColor.withAlpha(31),
),
), |
@houdayec hello, Thanks for your feedback. class _MainScreenState extends State<MainScreen> {
@override
Widget build(BuildContext context) {
final rtl = ZoomDrawer.isRTL();
return ValueListenableBuilder<DrawerState>(
valueListenable: ZoomDrawer.of(context).stateNotifier,
builder: (context, state, child) {
return (state != DrawerState.closed)? GestureDetector(
child: child,
onTap: () => ZoomDrawer.of(context).toggle(),
onPanUpdate: (details) {
if (details.delta.dx < 6 && !rtl || details.delta.dx < -6 && rtl) {
ZoomDrawer.of(context).toggle();
}
},
): child;
},
child: PageStructure(),
);
}
} |
Hi! Thanks for your answer and sorry for the late reply. I have tried this solution, but I finally encountered a problem: using this value listener forces child rebuild which is very annoying. Do you have the same problem using this solution? |
The ValueListenableBuilder will call it's builder function each time it get notified of a new drawer state. To minimize you page rebuilds you can provide the child parameter and use it in the builder function, same as the example. This will reduce the page rebuilds. In the example project, the PageStructure will only be built once, and then used from the child parameter. |
Yes that is what I did, I think I'm having child updates that lead to a widget rebuild. I'm going to investigate deeper. Thanks anyway for the workaround. |
Hi. Thanks for your package, really nice job.
However, I would like to know if it is possible to close the drawer when its opened, by swiping or clicking the view on the right.
Thanks in advance
The text was updated successfully, but these errors were encountered: