Skip to content

Commit cddd97c

Browse files
committed
appbar searchbox onClose fixed
1 parent ca2be1d commit cddd97c

File tree

2 files changed

+15
-26
lines changed

2 files changed

+15
-26
lines changed

lib/components/appbar/gf_appbar.dart

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,7 @@ class _GFAppBarState extends State<GFAppBar> {
408408
);
409409
}
410410

411-
searchBar = ListTile(
412-
contentPadding: EdgeInsets.zero,
413-
title: TextField(
411+
searchBar = TextField(
414412
cursorColor: widget.searchBarColorTheme,
415413
style: widget.searchTextStyle,
416414
decoration: new InputDecoration(
@@ -419,6 +417,19 @@ class _GFAppBarState extends State<GFAppBar> {
419417
color: widget.searchBarColorTheme,
420418
size: 18.0,
421419
),
420+
suffixIcon: GFIconButton(
421+
icon: Icon(
422+
Icons.close,
423+
color: widget.searchBarColorTheme,
424+
size: 20.0,
425+
),
426+
type: GFButtonType.transparent,
427+
onPressed: () {
428+
setState(() {
429+
showSearchBar = !showSearchBar;
430+
});
431+
},
432+
),
422433
hintText: widget.searchHintText,
423434
hintStyle: widget.searchHintStyle,
424435
focusedBorder: UnderlineInputBorder(
@@ -429,20 +440,6 @@ class _GFAppBarState extends State<GFAppBar> {
429440
onChanged: widget.onChanged,
430441
controller: widget.searchController,
431442
onSubmitted: widget.onSubmitted,
432-
),
433-
trailing: GFIconButton(
434-
icon: Icon(
435-
Icons.close,
436-
color: widget.searchBarColorTheme,
437-
size: 20.0,
438-
),
439-
type: GFButtonType.transparent,
440-
onPressed: () {
441-
setState(() {
442-
showSearchBar = !showSearchBar;
443-
});
444-
},
445-
),
446443
);
447444

448445
if (!showSearchBar) {

lib/components/search_bar/gf_search_bar.dart

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,7 @@ class MySingleChoiceSearchState<T> extends State<GFSearchBar<T>> {
158158
color: Theme.of(context).primaryColor,
159159
),
160160
),
161-
// suffixIcon: isFocused ?
162-
// GFIconButton(
163-
// icon: Icon(Icons.close),
164-
// type: GFButtonType.transparent,
165-
// onPressed: () {
166-
// onSearchListItemSelected(null);
167-
// },
168-
// )
169-
// : Icon(Icons.search),
161+
suffixIcon: isFocused ? Icon(Icons.close) : Icon(Icons.search),
170162
border: InputBorder.none,
171163
hintText: "Search here...",
172164
contentPadding: const EdgeInsets.only(

0 commit comments

Comments
 (0)