@@ -7,12 +7,22 @@ import 'package:redux/redux.dart';
77class SearchPopup extends StatelessWidget {
88 final Store <AppState > store;
99
10+ static const double minPrice = 0.0 ;
11+ static const double maxPrice = 100.0 ;
12+
13+ static const double minDistance = 0.0 ;
14+ static const double maxDistance = 600.0 ;
15+
1016 SearchPopup ({@required this .store});
1117
1218 @override
1319 Widget build (BuildContext context) {
1420 return new AlertDialog (
1521 actions: [
22+ new FlatButton (
23+ onPressed: () => store.dispatch (new ResetFiltersAction ()),
24+ child: const Text ('Réinitialiser' ),
25+ ),
1626 new FlatButton (
1727 onPressed: () => Navigator .pop (context),
1828 child: const Text ('OK' ),
@@ -23,26 +33,34 @@ class SearchPopup extends StatelessWidget {
2333 mainAxisSize: MainAxisSize .min,
2434 children: < Widget > [
2535 new ListTile (
26- leading: new Icon (Icons .location_city),
27- title: new StoreConnector <AppState , String >(
28- converter: (store) => store.state.cityFilter,
29- builder: (context, filter) {
30- return new TextField (
31- decoration: const InputDecoration (
32- hintText: 'Entrer le nom de la ville' ,
33- ),
34- onSubmitted: (String value) =>
35- store.dispatch (new UpdateCityFilterAction (value)),
36- );
37- },
38- )),
36+ leading: new Icon (Icons .location_city),
37+ title: new StoreConnector <AppState , String >(
38+ converter: (store) => store.state.cityFilter,
39+ builder: (context, city) {
40+ var cityFilterTextController =
41+ new TextEditingController (text: store.state.cityFilter)
42+ ..selection = new TextSelection (
43+ baseOffset: store.state.cityFilter.length,
44+ extentOffset: store.state.cityFilter.length,
45+ );
46+ return new TextField (
47+ controller: cityFilterTextController,
48+ decoration: const InputDecoration (
49+ hintText: 'Entrer le nom de la ville' ,
50+ ),
51+ onSubmitted: (String value) =>
52+ store.dispatch (new UpdateCityFilterAction (value)),
53+ );
54+ },
55+ ),
56+ ),
3957 new ListTile (
4058 leading: new Icon (Icons .attach_money),
4159 title: new StoreConnector <AppState , double >(
4260 builder: (context, price) => new Slider (
4361 value: price,
44- min: 0.0 ,
45- max: 100.0 ,
62+ min: minPrice ,
63+ max: maxPrice ,
4664 label: '${price .toStringAsFixed (0 )}\$ ' ,
4765 onChanged: (double value) => store.dispatch (
4866 new UpdatePriceFilterAction (value),
@@ -53,14 +71,13 @@ class SearchPopup extends StatelessWidget {
5371 new ListTile (
5472 leading: new Icon (Icons .directions_car),
5573 title: new StoreConnector <AppState , int >(
56- builder: (context, value) =>
57- new Slider (
74+ builder: (context, value) => new Slider (
5875 value: value.roundToDouble (),
59- max: 500.0 ,
76+ min: minDistance,
77+ max: maxDistance,
6078 label: '${value }km' ,
61- onChanged: (value) =>
62- store.dispatch (
63- new UpdateDistanceFilterAction (value.round ()))),
79+ onChanged: (value) => store.dispatch (
80+ new UpdateDistanceFilterAction (value.round ()))),
6481 converter: (store) => store.state.distanceFilter),
6582 ),
6683 ],
0 commit comments