11import 'package:flutter/widgets.dart' ;
22import 'package:flutter/foundation.dart' ;
33import 'package:flutter/material.dart' ;
4+ import 'package:getflutter/components/button/gf_icon_button.dart' ;
5+ import 'package:getflutter/getflutter.dart' ;
46
57class GFDrawerHeaderPictures extends StatelessWidget {
6- const GFDrawerHeaderPictures ({
7- Key key,
8- this .currentAccountPicture,
9- this .otherAccountsPictures,
10- }) : super (key: key);
8+ const GFDrawerHeaderPictures (
9+ {Key key,
10+ this .currentAccountPicture,
11+ this .otherAccountsPictures,
12+ this .closeButton})
13+ : super (key: key);
1114
1215 final Widget currentAccountPicture;
1316 final List <Widget > otherAccountsPictures;
1417
18+ /// widget onTap drawer get closed
19+ final Widget closeButton;
20+
1521 @override
1622 Widget build (BuildContext context) {
1723 return Stack (
1824 children: < Widget > [
25+ closeButton == null
26+ ? GFIconButton (
27+ icon: Icon (
28+ Icons .close,
29+ color: Colors .white,
30+ ),
31+ onPressed: (){
32+ Navigator .pop (context);
33+ },
34+ type: GFButtonType .transparent,
35+ )
36+ : closeButton,
1937 PositionedDirectional (
2038 top: 0.0 ,
2139 end: 0.0 ,
@@ -39,7 +57,7 @@ class GFDrawerHeaderPictures extends StatelessWidget {
3957 ),
4058 ),
4159 Positioned (
42- top: 0 .0 ,
60+ top: 40 .0 ,
4361 child: Semantics (
4462 explicitChildNodes: true ,
4563 child: SizedBox (
@@ -71,6 +89,7 @@ class GFDrawerHeader extends StatefulWidget {
7189 this .child,
7290 this .duration = const Duration (milliseconds: 250 ),
7391 this .curve = Curves .fastOutSlowIn,
92+ this .closeButton
7493 }) : super (key: key);
7594
7695 /// The header's background. If decoration is null then a [BoxDecoration]
@@ -103,6 +122,9 @@ class GFDrawerHeader extends StatefulWidget {
103122 /// The curve for animations of the [decoration] .
104123 final Curve curve;
105124
125+ /// widget onTap drawer get closed
126+ final Widget closeButton;
127+
106128 @override
107129 _GFDrawerHeaderState createState () => _GFDrawerHeaderState ();
108130}
@@ -112,10 +134,13 @@ class _GFDrawerHeaderState extends State<GFDrawerHeader> {
112134 Widget build (BuildContext context) {
113135 assert (debugCheckHasMaterial (context));
114136 assert (debugCheckHasMaterialLocalizations (context));
137+ final double statusBarHeight = MediaQuery .of (context).padding.top;
138+
115139 return Semantics (
116140 container: true ,
117141 label: MaterialLocalizations .of (context).signedInLabel,
118- child: DrawerHeader (
142+ child: Container (
143+ height: statusBarHeight + 185.0 ,
119144 decoration: widget.decoration ??
120145 BoxDecoration (
121146 color: Theme .of (context).primaryColor,
@@ -125,6 +150,7 @@ class _GFDrawerHeaderState extends State<GFDrawerHeader> {
125150 child: SafeArea (
126151 bottom: false ,
127152 child: Column (
153+ mainAxisAlignment: MainAxisAlignment .center,
128154 crossAxisAlignment: CrossAxisAlignment .stretch,
129155 children: < Widget > [
130156 Expanded (
@@ -133,14 +159,16 @@ class _GFDrawerHeaderState extends State<GFDrawerHeader> {
133159 child: GFDrawerHeaderPictures (
134160 currentAccountPicture: widget.currentAccountPicture,
135161 otherAccountsPictures: widget.otherAccountsPictures,
162+ closeButton: widget.closeButton,
136163 ),
137164 ),
138165 ),
139166 AnimatedContainer (
140- padding: EdgeInsets .only (bottom: 16.0 ),
141- duration: widget.duration,
142- curve: widget.curve,
143- child: widget.child),
167+ padding: EdgeInsets .only (bottom: 16.0 ),
168+ duration: widget.duration,
169+ curve: widget.curve,
170+ child: widget.child,
171+ ),
144172 ],
145173 ),
146174 ),
0 commit comments