@@ -16,10 +16,7 @@ class SearchData {
1616 String query;
1717 Order order;
1818
19- SearchData ({
20- @required this .query,
21- @required this .order
22- });
19+ SearchData ({@required this .query, @required this .order});
2320}
2421
2522class _SearchPageState extends State <SearchPage > {
@@ -41,47 +38,50 @@ class _SearchPageState extends State<SearchPage> {
4138 @override
4239 Widget build (BuildContext context) {
4340 return Scaffold (
44- resizeToAvoidBottomInset: false ,
45- appBar: AppBar (
46- title: Text (AppLocalizations .of (context).search),
47- actions: [],
48- ),
49- body: Column (
50- children: [
41+ resizeToAvoidBottomInset: false ,
42+ appBar: AppBar (
43+ title: Text (AppLocalizations .of (context).search),
44+ actions: [],
45+ ),
46+ body: Column (children: [
5147 Expanded (
52- child: ListView (
53- children: [
54- Card (
55- child: Container (
56- padding: EdgeInsets .all (10 ),
57- child: TextFormField (
58- textInputAction: TextInputAction .search,
59- onFieldSubmitted: (_) => _onSearch (),
60- autofocus: true ,
61- controller: queryController,
62- decoration: InputDecoration (labelText: AppLocalizations .of (context).keywords),
48+ child: ListView (
49+ children: [
50+ Card (
51+ child: Container (
52+ padding: EdgeInsets .all (10 ),
53+ child: TextFormField (
54+ textInputAction: TextInputAction .search,
55+ onFieldSubmitted: (_) => _onSearch (),
56+ autofocus: true ,
57+ controller: queryController,
58+ decoration: InputDecoration (
59+ labelText: AppLocalizations .of (context).keywords,
60+ suffixIcon: IconButton (
61+ icon: const Icon (Icons .clear),
62+ onPressed: () {
63+ queryController.clear ();
64+ },
65+ ),
6366 ),
64- )
65- ),
66- RadioGroup <Order >(
67- groupValue: orderBy,
68- title: AppLocalizations .of (context).sort,
69- enumToText: {
70- Order .Relevance : AppLocalizations .of (context).relevance,
71- Order .Date : AppLocalizations .of (context).date,
72- Order .Rating : AppLocalizations .of (context).rating,
73- },
67+ ),
7468 ),
75- ],
76- )
77- ),
69+ ),
70+ RadioGroup <Order >(
71+ groupValue: orderBy,
72+ title: AppLocalizations .of (context).sort,
73+ enumToText: {
74+ Order .Relevance : AppLocalizations .of (context).relevance,
75+ Order .Date : AppLocalizations .of (context).date,
76+ Order .Rating : AppLocalizations .of (context).rating,
77+ },
78+ ),
79+ ],
80+ )),
7881 Container (
79- padding: EdgeInsets .all (5 ),
80- child: SearchButton (onPressed: _onSearch)
81- ),
82- ]
83- )
84- );
82+ padding: EdgeInsets .all (5 ),
83+ child: SearchButton (onPressed: _onSearch)),
84+ ]));
8585 }
8686}
8787
@@ -90,36 +90,31 @@ class RadioGroup<Enum> extends StatelessWidget {
9090 final ValueNotifier <Enum > groupValue;
9191 final String title;
9292
93- RadioGroup ({
94- this .title,
95- @required this .groupValue,
96- @required this .enumToText});
93+ RadioGroup (
94+ {this .title, @required this .groupValue, @required this .enumToText});
9795
9896 @override
9997 Widget build (BuildContext context) {
10098 return Card (
101- child: ValueListenableBuilder <Enum >(
102- valueListenable: groupValue,
103- builder: (context, group, child) {
104- return Column (
99+ child: ValueListenableBuilder <Enum >(
100+ valueListenable: groupValue,
101+ builder: (context, group, child) {
102+ return Column (
105103 children: [
106- ListTile (
107- leading: Text (title),
108- trailing: Icon (Icons .sort),
109- )
110- ]..addAll (enumToText.keys.map <Widget >(
111- (e) => RadioListTile (
112- title: Text (enumToText[e]),
113- // activeColor: Colors.blueGrey,
114- value: e,
115- groupValue: group,
116- onChanged: (value) { groupValue.value = value; },
117- )
118- ))
119- );
120- },
121- )
122- );
104+ ListTile (
105+ leading: Text (title),
106+ trailing: Icon (Icons .sort),
107+ )
108+ ]..addAll (enumToText.keys.map <Widget >((e) => RadioListTile (
109+ title: Text (enumToText[e]),
110+ // activeColor: Colors.blueGrey,
111+ value: e,
112+ groupValue: group,
113+ onChanged: (value) {
114+ groupValue.value = value;
115+ },
116+ ))));
117+ },
118+ ));
123119 }
124-
125120}
0 commit comments