@@ -33,7 +33,7 @@ class _AllStopsState extends State<AllStopsPage> {
33
33
bool _networkStatus = false ;
34
34
35
35
final ScrollController _scrollController = ScrollController ();
36
- final TextEditingController _textController = new TextEditingController ();
36
+ final TextEditingController _textController = TextEditingController ();
37
37
38
38
Future <List <Stop >> fetchStops () async {
39
39
var url = 'https://api.magicsk.eu/stops2' ;
@@ -117,8 +117,7 @@ class _AllStopsState extends State<AllStopsPage> {
117
117
fetchStops ().then ((value) {
118
118
setState (() {
119
119
stops.addAll (value);
120
- getApplicationDocumentsDirectory ()
121
- .then ((Directory directory) {
120
+ getApplicationDocumentsDirectory ().then ((Directory directory) {
122
121
File file = new File (directory.path + "/" + stopsFileName);
123
122
file.createSync ();
124
123
file.writeAsStringSync (json.encode (stops));
@@ -133,9 +132,7 @@ class _AllStopsState extends State<AllStopsPage> {
133
132
}
134
133
print ('stops cleared' );
135
134
stops.sort ((a, b) {
136
- return a.name
137
- .toLowerCase ()
138
- .compareTo (b.name.toLowerCase ());
135
+ return a.name.toLowerCase ().compareTo (b.name.toLowerCase ());
139
136
});
140
137
print ('stops sorted' );
141
138
setState (() {
@@ -189,16 +186,14 @@ class _AllStopsState extends State<AllStopsPage> {
189
186
child: _isLoading
190
187
? CircularProgressIndicator ()
191
188
: DraggableScrollbar .semicircle (
189
+ backgroundColor: Theme .of (context).backgroundColor,
192
190
controller: _scrollController,
193
191
child: ListView .builder (
194
192
controller: _scrollController,
195
193
scrollDirection: Axis .vertical,
196
- itemCount:
197
- _savedForDisplay.length + _stopsForDisplay.length,
194
+ itemCount: _savedForDisplay.length + _stopsForDisplay.length,
198
195
itemBuilder: (context, index) {
199
- return index < _savedForDisplay.length
200
- ? _listSavedItem (index)
201
- : _listItem (index);
196
+ return index < _savedForDisplay.length ? _listSavedItem (index) : _listItem (index);
202
197
},
203
198
))),
204
199
);
@@ -212,10 +207,8 @@ class _AllStopsState extends State<AllStopsPage> {
212
207
hintText: AppLocalizations .of (context).searchHint,
213
208
contentPadding: EdgeInsets .only (top: 15.0 , bottom: 0.0 , left: 16.0 ),
214
209
hintStyle: TextStyle (color: Colors .white70),
215
- enabledBorder: UnderlineInputBorder (
216
- borderSide: BorderSide (color: Colors .white, width: 1.5 )),
217
- focusedBorder: UnderlineInputBorder (
218
- borderSide: BorderSide (color: Colors .white, width: 2.0 )),
210
+ enabledBorder: UnderlineInputBorder (borderSide: BorderSide (color: Colors .white, width: 1.5 )),
211
+ focusedBorder: UnderlineInputBorder (borderSide: BorderSide (color: Colors .white, width: 2.0 )),
219
212
suffixIcon: IconButton (
220
213
padding: EdgeInsets .only (top: 10.0 ),
221
214
icon: Icon (Icons .clear),
@@ -240,10 +233,7 @@ class _AllStopsState extends State<AllStopsPage> {
240
233
controller: _textController,
241
234
cursorColor: Colors .white,
242
235
maxLines: 1 ,
243
- style: TextStyle (
244
- fontSize: 20.0 ,
245
- color: Colors .white,
246
- decoration: TextDecoration .none),
236
+ style: TextStyle (fontSize: 20.0 , color: Colors .white, decoration: TextDecoration .none),
247
237
onChanged: (text) {
248
238
text = removeDiacritics (text).toLowerCase ();
249
239
setState (() {
@@ -265,61 +255,47 @@ class _AllStopsState extends State<AllStopsPage> {
265
255
index = index - _savedForDisplay.length;
266
256
return FlatButton (
267
257
onPressed: () {
268
- Navigator .push (
269
- context,
270
- MaterialPageRoute (
271
- builder: (context) => StopWebView (_stopsForDisplay[index])));
258
+ Navigator .push (context, MaterialPageRoute (builder: (context) => StopWebView (_stopsForDisplay[index])));
272
259
},
273
260
child: Column (
274
261
children: < Widget > [
275
- Row (
276
- mainAxisAlignment: MainAxisAlignment .spaceBetween,
277
- children: < Widget > [
278
- Column (
279
- crossAxisAlignment: CrossAxisAlignment .start,
280
- children: < Widget > [
281
- Padding (
282
- padding: const EdgeInsets .only (left: 16.0 ),
283
- child: Text (
284
- _stopsForDisplay[index].name,
285
- style: TextStyle (
286
- fontSize: 17.5 , fontWeight: FontWeight .normal),
287
- ),
262
+ Padding (
263
+ padding: const EdgeInsets .only (left: 16.0 , top: 4.0 , bottom: 4.0 ),
264
+ child: Flex (
265
+ direction: Axis .horizontal,
266
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
267
+ children: < Widget > [
268
+ Expanded (
269
+ child: Text (
270
+ _stopsForDisplay[index].name,
271
+ overflow: TextOverflow .ellipsis,
272
+ style: TextStyle (fontSize: 17.5 , fontWeight: FontWeight .normal),
288
273
),
289
- ],
290
- ),
291
- Padding (
292
- padding: const EdgeInsets .only (
293
- top: 4.0 , bottom: 4.0 , left: 0.0 , right: 0.0 ),
294
- child: IconButton (
274
+ ),
275
+ IconButton (
295
276
icon: Icon (Icons .star_border),
296
- color: null ,
297
277
onPressed: () {
298
278
setState (() {
299
279
saved.add (_stopsForDisplay[index]);
300
280
stops.remove (_stopsForDisplay[index]);
301
281
saved.sort ((a, b) {
302
- return a.name
303
- .toLowerCase ()
304
- .compareTo (b.name.toLowerCase ());
282
+ return a.name.toLowerCase ().compareTo (b.name.toLowerCase ());
305
283
});
306
284
var text = _textController.text;
307
285
_stopsForDisplay = stops.where ((stop) {
308
- var stopName =
309
- removeDiacritics (stop.name).toLowerCase ();
286
+ var stopName = removeDiacritics (stop.name).toLowerCase ();
310
287
return stopName.contains (text);
311
288
}).toList ();
312
289
_savedForDisplay = saved.where ((stop) {
313
- var stopName =
314
- removeDiacritics (stop.name).toLowerCase ();
290
+ var stopName = removeDiacritics (stop.name).toLowerCase ();
315
291
return stopName.contains (text);
316
292
}).toList ();
317
293
createFile ();
318
294
});
319
295
},
320
296
),
321
- ) ,
322
- ] ,
297
+ ] ,
298
+ ) ,
323
299
),
324
300
Divider (
325
301
height: 2.0 ,
@@ -332,10 +308,7 @@ class _AllStopsState extends State<AllStopsPage> {
332
308
_listSavedItem (index) {
333
309
return FlatButton (
334
310
onPressed: () {
335
- Navigator .push (
336
- context,
337
- MaterialPageRoute (
338
- builder: (context) => StopWebView (_savedForDisplay[index])));
311
+ Navigator .push (context, MaterialPageRoute (builder: (context) => StopWebView (_savedForDisplay[index])));
339
312
},
340
313
child: Column (
341
314
children: < Widget > [
@@ -349,15 +322,13 @@ class _AllStopsState extends State<AllStopsPage> {
349
322
padding: const EdgeInsets .only (left: 16.0 ),
350
323
child: Text (
351
324
_savedForDisplay[index].name,
352
- style: TextStyle (
353
- fontSize: 17.5 , fontWeight: FontWeight .normal),
325
+ style: TextStyle (fontSize: 17.5 , fontWeight: FontWeight .normal),
354
326
),
355
327
),
356
328
],
357
329
),
358
330
Padding (
359
- padding: const EdgeInsets .only (
360
- top: 4.0 , bottom: 4.0 , left: 0.0 , right: 0.0 ),
331
+ padding: const EdgeInsets .only (top: 4.0 , bottom: 4.0 , left: 0.0 , right: 0.0 ),
361
332
child: IconButton (
362
333
icon: Icon (Icons .star),
363
334
color: Colors .yellow[800 ],
@@ -366,19 +337,15 @@ class _AllStopsState extends State<AllStopsPage> {
366
337
stops.add (_savedForDisplay[index]);
367
338
saved.remove (_savedForDisplay[index]);
368
339
stops.sort ((a, b) {
369
- return a.name
370
- .toLowerCase ()
371
- .compareTo (b.name.toLowerCase ());
340
+ return a.name.toLowerCase ().compareTo (b.name.toLowerCase ());
372
341
});
373
342
var text = _textController.text;
374
343
_stopsForDisplay = stops.where ((stop) {
375
- var stopName =
376
- removeDiacritics (stop.name).toLowerCase ();
344
+ var stopName = removeDiacritics (stop.name).toLowerCase ();
377
345
return stopName.contains (text);
378
346
}).toList ();
379
347
_savedForDisplay = saved.where ((stop) {
380
- var stopName =
381
- removeDiacritics (stop.name).toLowerCase ();
348
+ var stopName = removeDiacritics (stop.name).toLowerCase ();
382
349
return stopName.contains (text);
383
350
}).toList ();
384
351
createFile ();
0 commit comments