Skip to content

Commit 9ab8a37

Browse files
authored
Merge pull request #71 from deepikahr/searchBar
Search bar
2 parents fc5dafd + d82b8d5 commit 9ab8a37

File tree

4 files changed

+157
-125
lines changed

4 files changed

+157
-125
lines changed

example/lib/main.dart

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ class _MyHomePageState extends State<MyHomePage>
7474
Widget build(BuildContext context) {
7575
return Scaffold(
7676
drawer: GFDrawer(
77-
colorFilter: new ColorFilter.mode(
78-
Colors.black.withOpacity(0.6), BlendMode.darken),
79-
backgroundImage: NetworkImage(
80-
"https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg"),
77+
// colorFilter: new ColorFilter.mode(
78+
// Colors.teal.withOpacity(0.6), BlendMode.darken),
79+
// backgroundImage: NetworkImage(
80+
// "https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg"),
8181
gradient: LinearGradient(
8282
begin: Alignment.topRight,
8383
end: Alignment.bottomLeft,
@@ -89,6 +89,7 @@ class _MyHomePageState extends State<MyHomePage>
8989
Colors.teal[200],
9090
],
9191
),
92+
color: Colors.greenAccent,
9293
child: ListView(
9394
padding: EdgeInsets.zero,
9495
children: <Widget>[
@@ -99,7 +100,7 @@ class _MyHomePageState extends State<MyHomePage>
99100
"https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg"),
100101
),
101102
decoration: BoxDecoration(
102-
color: Colors.teal.withOpacity(0.45),
103+
color: Colors.transparent,
103104
),
104105
otherAccountsPictures: <Widget>[
105106
Image(
@@ -115,20 +116,18 @@ class _MyHomePageState extends State<MyHomePage>
115116
mainAxisAlignment: MainAxisAlignment.start,
116117
crossAxisAlignment: CrossAxisAlignment.start,
117118
children: <Widget>[
118-
Text('user'),
119-
Text('user@asdf.com'),
119+
Text('user name'),
120+
Text('user@userid.com'),
120121
],
121122
),
122123
),
123124
ListTile(
124125
title: Text('Item 1'),
125-
onTap: () {
126-
Navigator.pop(context);
127-
},
126+
onTap: null,
128127
),
129128
ListTile(
130129
title: Text('Item 2'),
131-
onTap: () {},
130+
onTap: null,
132131
),
133132
],
134133
),
@@ -182,8 +181,8 @@ class _MyHomePageState extends State<MyHomePage>
182181
children: <Widget>[
183182
GFSearchBar(
184183
searchList: list,
185-
hideSearchBoxWhenItemSelected: false,
186-
overlaySearchListHeight: 100.0,
184+
// hideSearchBoxWhenItemSelected: false,
185+
// overlaySearchListHeight: 100.0,
187186
searchQueryBuilder: (query, list) {
188187
return list
189188
.where((item) =>
@@ -192,17 +191,17 @@ class _MyHomePageState extends State<MyHomePage>
192191
},
193192
overlaySearchListItemBuilder: (item) {
194193
return Container(
195-
padding: const EdgeInsets.all(12),
194+
padding: const EdgeInsets.all(8),
196195
child: Text(
197196
item,
198197
style: const TextStyle(fontSize: 18),
199198
),
200199
);
201200
},
202-
noItemsFoundWidget: Container(
203-
color: Colors.green,
204-
child: Text("no items found"),
205-
),
201+
// noItemsFoundWidget: Container(
202+
// color: Colors.green,
203+
// child: Text("no items found..."),
204+
// ),
206205
onItemSelected: (item) {
207206
setState(() {
208207
print('ssssssss $item');

lib/components/appbar/gf_appbar.dart

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -408,41 +408,38 @@ class _GFAppBarState extends State<GFAppBar> {
408408
);
409409
}
410410

411-
searchBar = ListTile(
412-
contentPadding: EdgeInsets.zero,
413-
title: TextField(
414-
cursorColor: widget.searchBarColorTheme,
415-
style: widget.searchTextStyle,
416-
decoration: new InputDecoration(
417-
prefixIcon: new Icon(
418-
Icons.search,
411+
searchBar = TextField(
412+
cursorColor: widget.searchBarColorTheme,
413+
style: widget.searchTextStyle,
414+
decoration: new InputDecoration(
415+
prefixIcon: new Icon(
416+
Icons.search,
417+
color: widget.searchBarColorTheme,
418+
size: 18.0,
419+
),
420+
suffixIcon: GFIconButton(
421+
icon: Icon(
422+
Icons.close,
419423
color: widget.searchBarColorTheme,
420-
size: 18.0,
421-
),
422-
hintText: widget.searchHintText,
423-
hintStyle: widget.searchHintStyle,
424-
focusedBorder: UnderlineInputBorder(
425-
borderSide: BorderSide(width: 1, color: widget.searchBarColorTheme),
424+
size: 20.0,
426425
),
426+
type: GFButtonType.transparent,
427+
onPressed: () {
428+
setState(() {
429+
showSearchBar = !showSearchBar;
430+
});
431+
},
427432
),
428-
onTap: widget.onTap,
429-
onChanged: widget.onChanged,
430-
controller: widget.searchController,
431-
onSubmitted: widget.onSubmitted,
432-
),
433-
trailing: GFIconButton(
434-
icon: Icon(
435-
Icons.close,
436-
color: widget.searchBarColorTheme,
437-
size: 20.0,
433+
hintText: widget.searchHintText,
434+
hintStyle: widget.searchHintStyle,
435+
focusedBorder: UnderlineInputBorder(
436+
borderSide: BorderSide(width: 1, color: widget.searchBarColorTheme),
438437
),
439-
type: GFButtonType.transparent,
440-
onPressed: () {
441-
setState(() {
442-
showSearchBar = !showSearchBar;
443-
});
444-
},
445438
),
439+
onTap: widget.onTap,
440+
onChanged: widget.onChanged,
441+
controller: widget.searchController,
442+
onSubmitted: widget.onSubmitted,
446443
);
447444

448445
if (!showSearchBar) {

lib/components/drawer/gf_drawer.dart

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,16 @@ class GFDrawer extends StatelessWidget {
5757
/// Typically used in the [Scaffold.drawer] property.
5858
///
5959
/// The [elevation] must be non-negative.
60-
const GFDrawer(
61-
{Key key,
62-
this.elevation = 16.0,
63-
this.child,
64-
this.semanticLabel,
65-
this.backgroundImage,
66-
this.colorFilter,
67-
this.gradient})
68-
: assert(elevation != null && elevation >= 0.0),
60+
const GFDrawer({
61+
Key key,
62+
this.elevation = 16.0,
63+
this.child,
64+
this.semanticLabel,
65+
this.backgroundImage,
66+
this.colorFilter,
67+
this.gradient,
68+
this.color,
69+
}) : assert(elevation != null && elevation >= 0.0),
6970
super(key: key);
7071

7172
/// The z-coordinate at which to place this drawer relative to its parent.
@@ -105,6 +106,9 @@ class GFDrawer extends StatelessWidget {
105106
/// applying the same transform to the entire canvas.
106107
final Gradient gradient;
107108

109+
/// Defines the background color of the drawer
110+
final dynamic color;
111+
108112
@override
109113
Widget build(BuildContext context) {
110114
assert(debugCheckHasMaterialLocalizations(context));
@@ -131,7 +135,7 @@ class GFDrawer extends StatelessWidget {
131135
elevation: elevation,
132136
child: Container(
133137
decoration: new BoxDecoration(
134-
color: Colors.teal,
138+
color: color,
135139
gradient: gradient,
136140
image: backgroundImage != null
137141
? new DecorationImage(

0 commit comments

Comments
 (0)