Skip to content

Commit c3f3466

Browse files
committed
searchbar definations completed
1 parent 46cce1c commit c3f3466

File tree

3 files changed

+66
-58
lines changed

3 files changed

+66
-58
lines changed

example/lib/main.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:getflutter/getflutter.dart';
33
import 'package:getflutter/components/search_bar/gf_search_bar.dart';
4-
import 'dart:io';
54

65
final List<String> imageList = [
76
"https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg",
@@ -157,7 +156,14 @@ class _MyHomePageState extends State<MyHomePage>
157156

158157
actions: <Widget>[
159158
// GFIconButton(icon: Icon(Icons.access_time), onPressed: () {}),
160-
GFIconButton(icon: Icon(Icons.favorite, color: Colors.white,), onPressed: (){}, type: GFButtonType.transparent,),
159+
GFIconButton(
160+
icon: Icon(
161+
Icons.favorite,
162+
color: Colors.white,
163+
),
164+
onPressed: () {},
165+
type: GFButtonType.transparent,
166+
),
161167
],
162168
),
163169
// backgroundColor: Colors.blueGrey,
@@ -175,7 +181,6 @@ class _MyHomePageState extends State<MyHomePage>
175181
mainAxisAlignment: MainAxisAlignment.center,
176182
crossAxisAlignment: CrossAxisAlignment.center,
177183
children: <Widget>[
178-
179184
GFSearchBar(
180185
searchList: list,
181186
hideSearchBoxWhenItemSelected: false,
@@ -774,7 +779,7 @@ class _MyHomePageState extends State<MyHomePage>
774779
).toList(),
775780
onPageChanged: (index) {
776781
setState(() {
777-
index;
782+
// index;
778783
});
779784
},
780785
),

lib/components/card/gf_card.dart

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ class GFCard extends StatelessWidget {
3636
this.gradient})
3737
: assert(elevation == null || elevation >= 0.0),
3838
assert(borderOnForeground != null),
39-
assert(color == null || gradient == null,
40-
'Cannot provide both a color and a decoration\n'
41-
'The color argument is just a shorthand for "decoration: new BoxDecoration(color: color)".'
42-
),
39+
assert(
40+
color == null || gradient == null,
41+
'Cannot provide both a color and a decoration\n'
42+
'The color argument is just a shorthand for "decoration: new BoxDecoration(color: color)".'),
4343
super(key: key);
4444

4545
/// defines the card's height
@@ -149,23 +149,29 @@ class GFCard extends StatelessWidget {
149149
return Container(
150150
height: height,
151151
margin: margin ?? cardTheme.margin ?? const EdgeInsets.all(16.0),
152-
decoration: gradient != null ? BoxDecoration(
153-
gradient: gradient,
154-
borderRadius: BorderRadius.all(Radius.circular(4.0)),
155-
) : null,
156-
child: gradient == null ? Material(
157-
type: MaterialType.card,
158-
color: color ?? cardTheme.color ?? Theme.of(context).cardColor,
159-
elevation: elevation ?? cardTheme.elevation ?? _defaultElevation,
160-
shape: shape ??
161-
cardTheme.shape ??
162-
const RoundedRectangleBorder(
152+
decoration: gradient != null
153+
? BoxDecoration(
154+
gradient: gradient,
163155
borderRadius: BorderRadius.all(Radius.circular(4.0)),
164-
),
165-
borderOnForeground: borderOnForeground,
166-
clipBehavior: clipBehavior ?? cardTheme.clipBehavior ?? _defaultClipBehavior,
167-
child: imageOverlay == null ? cardChild : overlayImage,
168-
) : imageOverlay == null ? cardChild : overlayImage,
156+
)
157+
: null,
158+
child: gradient == null
159+
? Material(
160+
type: MaterialType.card,
161+
color: color ?? cardTheme.color ?? Theme.of(context).cardColor,
162+
elevation: elevation ?? cardTheme.elevation ?? _defaultElevation,
163+
shape: shape ??
164+
cardTheme.shape ??
165+
const RoundedRectangleBorder(
166+
borderRadius: BorderRadius.all(Radius.circular(4.0)),
167+
),
168+
borderOnForeground: borderOnForeground,
169+
clipBehavior: clipBehavior ??
170+
cardTheme.clipBehavior ??
171+
_defaultClipBehavior,
172+
child: imageOverlay == null ? cardChild : overlayImage,
173+
)
174+
: imageOverlay == null ? cardChild : overlayImage,
169175
);
170176
}
171177
}

lib/components/search_bar/gf_search_bar.dart

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class GFSearchBar<T> extends StatefulWidget {
1919
this.noItemsFoundWidget,
2020
}) : super(key: key);
2121

22-
2322
/// List of [text] or [widget] reference for users
2423
final List<T> searchList;
2524

@@ -131,38 +130,37 @@ class MySingleChoiceSearchState<T> extends State<GFSearchBar<T>> {
131130

132131
@override
133132
Widget build(BuildContext context) {
134-
135-
overlaySearchListHeight =
136-
widget.overlaySearchListHeight ?? MediaQuery.of(context).size.height / 4;
133+
overlaySearchListHeight = widget.overlaySearchListHeight ??
134+
MediaQuery.of(context).size.height / 4;
137135
searchBox = Padding(
138-
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
139-
child: TextField(
140-
controller: _controller,
141-
focusNode: _focusNode,
142-
style: TextStyle(fontSize: 16, color: Colors.grey[600]),
143-
decoration: InputDecoration(
144-
enabledBorder: const OutlineInputBorder(
145-
borderSide: BorderSide(
146-
color: Color(0x4437474F),
147-
),
148-
),
149-
focusedBorder: OutlineInputBorder(
150-
borderSide: BorderSide(
151-
color: Theme.of(context).primaryColor,
152-
),
153-
),
154-
suffixIcon: Icon(Icons.search),
155-
border: InputBorder.none,
156-
hintText: "Search here...",
157-
contentPadding: const EdgeInsets.only(
158-
left: 16,
159-
right: 20,
160-
top: 14,
161-
bottom: 14,
162-
),
163-
),
136+
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
137+
child: TextField(
138+
controller: _controller,
139+
focusNode: _focusNode,
140+
style: TextStyle(fontSize: 16, color: Colors.grey[600]),
141+
decoration: InputDecoration(
142+
enabledBorder: const OutlineInputBorder(
143+
borderSide: BorderSide(
144+
color: Color(0x4437474F),
164145
),
165-
);
146+
),
147+
focusedBorder: OutlineInputBorder(
148+
borderSide: BorderSide(
149+
color: Theme.of(context).primaryColor,
150+
),
151+
),
152+
suffixIcon: Icon(Icons.search),
153+
border: InputBorder.none,
154+
hintText: "Search here...",
155+
contentPadding: const EdgeInsets.only(
156+
left: 16,
157+
right: 20,
158+
top: 14,
159+
bottom: 14,
160+
),
161+
),
162+
),
163+
);
166164

167165
final column = Column(
168166
mainAxisSize: MainAxisSize.min,
@@ -248,7 +246,8 @@ class MySingleChoiceSearchState<T> extends State<GFSearchBar<T>> {
248246
itemBuilder: (context, index) => Material(
249247
color: Colors.transparent,
250248
child: InkWell(
251-
onTap: () => onSearchListItemSelected(_searchList[index]),
249+
onTap: () =>
250+
onSearchListItemSelected(_searchList[index]),
252251
child: widget.overlaySearchListItemBuilder(
253252
_searchList.elementAt(index),
254253
),
@@ -274,8 +273,6 @@ class MySingleChoiceSearchState<T> extends State<GFSearchBar<T>> {
274273
}
275274
}
276275

277-
278-
279276
//class GFSearch extends StatefulWidget {
280277
// @override
281278
// _GFSearchState createState() => new _GFSearchState();

0 commit comments

Comments
 (0)