From e984f7eba58e876811247ff6bad9415d1ab473e3 Mon Sep 17 00:00:00 2001 From: NikhilVadoliya Date: Sat, 14 Nov 2020 10:07:14 +0530 Subject: [PATCH] :sparkles: - provide animationController --- example/lib/main.dart | 4 +--- lib/src/slider.dart | 56 ++++--------------------------------------- 2 files changed, 5 insertions(+), 55 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index be32ffd..d8dc35b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -16,7 +16,7 @@ class MyApp extends StatefulWidget { class _MyAppState extends State { GlobalKey _key = - new GlobalKey(); + new GlobalKey(); String title; @override @@ -36,9 +36,7 @@ class _MyAppState extends State { appBarPadding: const EdgeInsets.only(top: 20), sliderMenuOpenSize: 200, sliderMenuCloseSize: 60, - // slideDirection: SlideDirection.TOP_TO_BOTTOM, appBarHeight: 60, - // isShadow: true, title: Text( title, style: TextStyle(fontSize: 22, fontWeight: FontWeight.w700), diff --git a/lib/src/slider.dart b/lib/src/slider.dart index f553e74..09a2246 100644 --- a/lib/src/slider.dart +++ b/lib/src/slider.dart @@ -58,11 +58,6 @@ class SliderMenuContainer extends StatefulWidget { class SliderMenuContainerState extends State with TickerProviderStateMixin { - double _slideBarXOffset = 0; - double _slideBarYOffset = 0; - bool _isSlideBarOpen = false; - - // AnimationController _animationButtonController; AnimationController _animationDrawerController; Animation animation; @@ -71,67 +66,24 @@ class SliderMenuContainerState extends State /// check whether drawer is open bool get isDrawerOpen => _animationDrawerController.isCompleted; + AnimationController get animationController => _animationDrawerController; + /// Toggle drawer void toggle() { _animationDrawerController.isCompleted ? _animationDrawerController.reverse() : _animationDrawerController.forward(); - /*setState(() { - _isSlideBarOpen - ? _animationButtonController.reverse() - : _animationButtonController.forward(); - if (widget.sliderOpen == SliderOpen.LEFT_TO_RIGHT || - widget.sliderOpen == SliderOpen.RIGHT_TO_LEFT) { - _slideBarXOffset = _isSlideBarOpen - ? widget.sliderMenuCloseOffset - : widget.sliderMenuOpenOffset; - } else { - _slideBarYOffset = _isSlideBarOpen - ? widget.sliderMenuCloseOffset - : widget.sliderMenuOpenOffset; - } - - _isSlideBarOpen = !_isSlideBarOpen; - });*/ } /// Open drawer - void openDrawer() { - _animationDrawerController.forward(); - /*setState(() { - _animationButtonController.forward(); - if (widget.sliderOpen == SliderOpen.LEFT_TO_RIGHT || - widget.sliderOpen == SliderOpen.RIGHT_TO_LEFT) { - _slideBarXOffset = widget.sliderMenuOpenOffset; - } else { - _slideBarYOffset = widget.sliderMenuOpenOffset; - } - _isSlideBarOpen = true; - });*/ - } + void openDrawer() => _animationDrawerController.forward(); /// Close drawer - void closeDrawer() { - _animationDrawerController.reverse(); - /* setState(() { - _animationButtonController.reverse(); - if (widget.sliderOpen == SliderOpen.LEFT_TO_RIGHT || - widget.sliderOpen == SliderOpen.RIGHT_TO_LEFT) { - _slideBarXOffset = widget.sliderMenuCloseOffset; - } else { - _slideBarYOffset = widget.sliderMenuCloseOffset; - } - _isSlideBarOpen = false; - });*/ - } + void closeDrawer() => _animationDrawerController.reverse(); @override void initState() { super.initState(); - /* _animationButtonController = AnimationController( - vsync: this, - duration: - Duration(milliseconds: widget.sliderAnimationTimeInMilliseconds));*/ _animationDrawerController = AnimationController( vsync: this,