@@ -26,7 +26,8 @@ class DrawerUserController extends StatefulWidget {
2626 _DrawerUserControllerState createState () => _DrawerUserControllerState ();
2727}
2828
29- class _DrawerUserControllerState extends State <DrawerUserController > with TickerProviderStateMixin {
29+ class _DrawerUserControllerState extends State <DrawerUserController >
30+ with TickerProviderStateMixin {
3031 ScrollController ? scrollController;
3132 AnimationController ? iconAnimationController;
3233 AnimationController ? animationController;
@@ -35,10 +36,16 @@ class _DrawerUserControllerState extends State<DrawerUserController> with Ticker
3536
3637 @override
3738 void initState () {
38- animationController = AnimationController (duration: const Duration (milliseconds: 2000 ), vsync: this );
39- iconAnimationController = AnimationController (vsync: this , duration: const Duration (milliseconds: 0 ));
40- iconAnimationController? ..animateTo (1.0 , duration: const Duration (milliseconds: 0 ), curve: Curves .fastOutSlowIn);
41- scrollController = ScrollController (initialScrollOffset: widget.drawerWidth);
39+ animationController = AnimationController (
40+ duration: const Duration (milliseconds: 2000 ), vsync: this );
41+ iconAnimationController = AnimationController (
42+ vsync: this , duration: const Duration (milliseconds: 0 ));
43+ iconAnimationController
44+ ? ..animateTo (1.0 ,
45+ duration: const Duration (milliseconds: 0 ),
46+ curve: Curves .fastOutSlowIn);
47+ scrollController =
48+ ScrollController (initialScrollOffset: widget.drawerWidth);
4249 scrollController!
4350 ..addListener (() {
4451 if (scrollController! .offset <= 0 ) {
@@ -50,10 +57,15 @@ class _DrawerUserControllerState extends State<DrawerUserController> with Ticker
5057 } catch (_) {}
5158 });
5259 }
53- iconAnimationController? .animateTo (0.0 , duration: const Duration (milliseconds: 0 ), curve: Curves .fastOutSlowIn);
54- } else if (scrollController! .offset > 0 && scrollController! .offset < widget.drawerWidth.floor ()) {
55- iconAnimationController? .animateTo ((scrollController! .offset * 100 / (widget.drawerWidth)) / 100 ,
56- duration: const Duration (milliseconds: 0 ), curve: Curves .fastOutSlowIn);
60+ iconAnimationController? .animateTo (0.0 ,
61+ duration: const Duration (milliseconds: 0 ),
62+ curve: Curves .fastOutSlowIn);
63+ } else if (scrollController! .offset > 0 &&
64+ scrollController! .offset < widget.drawerWidth.floor ()) {
65+ iconAnimationController? .animateTo (
66+ (scrollController! .offset * 100 / (widget.drawerWidth)) / 100 ,
67+ duration: const Duration (milliseconds: 0 ),
68+ curve: Curves .fastOutSlowIn);
5769 } else {
5870 if (scrolloffset != 0.0 ) {
5971 setState (() {
@@ -63,7 +75,9 @@ class _DrawerUserControllerState extends State<DrawerUserController> with Ticker
6375 } catch (_) {}
6476 });
6577 }
66- iconAnimationController? .animateTo (1.0 , duration: const Duration (milliseconds: 0 ), curve: Curves .fastOutSlowIn);
78+ iconAnimationController? .animateTo (1.0 ,
79+ duration: const Duration (milliseconds: 0 ),
80+ curve: Curves .fastOutSlowIn);
6781 }
6882 });
6983 WidgetsBinding .instance? .addPostFrameCallback ((_) => getInitState ());
@@ -79,8 +93,10 @@ class _DrawerUserControllerState extends State<DrawerUserController> with Ticker
7993
8094 @override
8195 Widget build (BuildContext context) {
96+ var brightness = MediaQuery .of (context).platformBrightness;
97+ bool isLightMode = brightness == Brightness .light;
8298 return Scaffold (
83- backgroundColor: AppTheme .white,
99+ backgroundColor: isLightMode ? AppTheme .white : AppTheme .nearlyBlack ,
84100 body: SingleChildScrollView (
85101 controller: scrollController,
86102 scrollDirection: Axis .horizontal,
@@ -100,9 +116,12 @@ class _DrawerUserControllerState extends State<DrawerUserController> with Ticker
100116 builder: (BuildContext context, Widget ? child) {
101117 return Transform (
102118 //transform we use for the stable drawer we, not need to move with scroll view
103- transform: Matrix4 .translationValues (scrollController! .offset, 0.0 , 0.0 ),
119+ transform: Matrix4 .translationValues (
120+ scrollController! .offset, 0.0 , 0.0 ),
104121 child: HomeDrawer (
105- screenIndex: widget.screenIndex == null ? DrawerIndex .HOME : widget.screenIndex,
122+ screenIndex: widget.screenIndex == null
123+ ? DrawerIndex .HOME
124+ : widget.screenIndex,
106125 iconAnimationController: iconAnimationController,
107126 callBackIndex: (DrawerIndex indexType) {
108127 onDrawerClick ();
@@ -123,7 +142,9 @@ class _DrawerUserControllerState extends State<DrawerUserController> with Ticker
123142 decoration: BoxDecoration (
124143 color: AppTheme .white,
125144 boxShadow: < BoxShadow > [
126- BoxShadow (color: AppTheme .grey.withOpacity (0.6 ), blurRadius: 24 ),
145+ BoxShadow (
146+ color: AppTheme .grey.withOpacity (0.6 ),
147+ blurRadius: 24 ),
127148 ],
128149 ),
129150 child: Stack (
@@ -142,24 +163,32 @@ class _DrawerUserControllerState extends State<DrawerUserController> with Ticker
142163 ),
143164 // this just menu and arrow icon animation
144165 Padding (
145- padding: EdgeInsets .only (top: MediaQuery .of (context).padding.top + 8 , left: 8 ),
166+ padding: EdgeInsets .only (
167+ top: MediaQuery .of (context).padding.top + 8 ,
168+ left: 8 ),
146169 child: SizedBox (
147170 width: AppBar ().preferredSize.height - 8 ,
148171 height: AppBar ().preferredSize.height - 8 ,
149172 child: Material (
150173 color: Colors .transparent,
151174 child: InkWell (
152- borderRadius: BorderRadius .circular (AppBar ().preferredSize.height),
175+ borderRadius: BorderRadius .circular (
176+ AppBar ().preferredSize.height),
153177 child: Center (
154178 // if you use your own menu view UI you add form initialization
155179 child: widget.menuView != null
156180 ? widget.menuView
157181 : AnimatedIcon (
158- icon: widget.animatedIconData ?? AnimatedIcons .arrow_menu,
182+ color: isLightMode
183+ ? AppTheme .dark_grey
184+ : AppTheme .white,
185+ icon: widget.animatedIconData ??
186+ AnimatedIcons .arrow_menu,
159187 progress: iconAnimationController! ),
160188 ),
161189 onTap: () {
162- FocusScope .of (context).requestFocus (FocusNode ());
190+ FocusScope .of (context)
191+ .requestFocus (FocusNode ());
163192 onDrawerClick ();
164193 },
165194 ),
0 commit comments