Skip to content

Commit b224f20

Browse files
authored
Merge pull request #72 from deepikahr/searchBar
drawer haeder close button completed
2 parents 2b4cb39 + 0228948 commit b224f20

File tree

2 files changed

+48
-16
lines changed

2 files changed

+48
-16
lines changed

example/lib/main.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class _MyHomePageState extends State<MyHomePage>
100100
"https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg"),
101101
),
102102
decoration: BoxDecoration(
103-
color: Colors.transparent,
103+
color: Colors.teal,
104104
),
105105
otherAccountsPictures: <Widget>[
106106
Image(
@@ -112,6 +112,7 @@ class _MyHomePageState extends State<MyHomePage>
112112
child: Text("dcf"),
113113
)
114114
],
115+
// closeButton: Text("Close"),
115116
child: Column(
116117
mainAxisAlignment: MainAxisAlignment.start,
117118
crossAxisAlignment: CrossAxisAlignment.start,
@@ -174,6 +175,8 @@ class _MyHomePageState extends State<MyHomePage>
174175
// Container(color: Colors.green),
175176
// Container(color: Colors.blue)
176177
// ]),
178+
179+
177180
SingleChildScrollView(
178181
child: Column(
179182
mainAxisAlignment: MainAxisAlignment.center,
@@ -645,6 +648,7 @@ class _MyHomePageState extends State<MyHomePage>
645648
// ),
646649
//
647650
GFButton(
651+
// position: GFPosition.end,
648652
// icon: GFBadge(
649653
// child: Text("12"),
650654
// color: GFColor.dark,
@@ -661,9 +665,9 @@ class _MyHomePageState extends State<MyHomePage>
661665
// hoverColor: GFColor.dark,
662666
color: GFColor.secondary,
663667
// focusColor: GFColor.danger,
664-
type: GFButtonType.solid,
665-
shape: GFButtonShape.pills,
666-
buttonBoxShadow: true,
668+
// type: GFButtonType.solid,
669+
// shape: GFButtonShape.pills,
670+
// buttonBoxShadow: true,
667671
// boxShadow: BoxShadow(
668672
// color: Colors.pink,
669673
// blurRadius: 2.0,
@@ -675,7 +679,7 @@ class _MyHomePageState extends State<MyHomePage>
675679
// size: GFSize.large,
676680
// disabledColor: GFColor.dark,
677681
// disabledTextColor: GFColor.light,
678-
blockButton: true,
682+
// blockButton: true,
679683
// fullWidthButton: true,
680684
// borderSide: BorderSide(color: Colors.pink, width: 1.0, style: BorderStyle.solid),
681685
// borderShape: RoundedRectangleBorder(side: BorderSide(color: Colors.pink, width: 2.0, style: BorderStyle.solid), borderRadius: BorderRadius.zero),

lib/components/drawer/gf_drawer_header.dart

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,39 @@
11
import 'package:flutter/widgets.dart';
22
import 'package:flutter/foundation.dart';
33
import 'package:flutter/material.dart';
4+
import 'package:getflutter/components/button/gf_icon_button.dart';
5+
import 'package:getflutter/getflutter.dart';
46

57
class 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

Comments
 (0)