Skip to content
This repository was archived by the owner on Dec 17, 2023. It is now read-only.

Commit 8b20b3f

Browse files
committed
fixed Trip planner
1 parent 9092182 commit 8b20b3f

File tree

4 files changed

+82
-51
lines changed

4 files changed

+82
-51
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/sh
22
# This is a generated file; do not edit or check into version control.
3-
export "FLUTTER_ROOT=C:\Users\magic_sk\Downloads\dev\flutter"
4-
export "FLUTTER_APPLICATION_PATH=C:\Users\magic_sk\Downloads\dev\mhd_virtual_table"
3+
export "FLUTTER_ROOT=C:\Users\magic_sk\Development\flutter"
4+
export "FLUTTER_APPLICATION_PATH=C:\Users\magic_sk\Development\mhd_virtual_table"
55
export "FLUTTER_TARGET=lib\main.dart"
66
export "FLUTTER_BUILD_DIR=build"
77
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
8-
export "FLUTTER_FRAMEWORK_DIR=C:\Users\magic_sk\Downloads\dev\flutter\bin\cache\artifacts\engine\ios"
8+
export "FLUTTER_FRAMEWORK_DIR=C:\Users\magic_sk\Development\flutter\bin\cache\artifacts\engine\ios"
99
export "FLUTTER_BUILD_NAME=1.0.0"
1010
export "FLUTTER_BUILD_NUMBER=1.0.0"

lib/NearMe.dart

Lines changed: 69 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class _NearMeState extends State<NearMePage> {
3030
bool _locationStatus = false;
3131
bool _networkStatus = false;
3232
bool _restricted = false;
33+
bool _error = false;
3334
int tableThemeInt;
3435

3536
_getprefs() async {
@@ -112,13 +113,13 @@ class _NearMeState extends State<NearMePage> {
112113
nearStops.addAll(_nearStopsFile);
113114
print('nearStops loaded');
114115
_getprefs().then((permission) {
115-
_checkLocationStatus().then((status) {
116-
setState(() {
117-
_locationStatus = status;
118-
_gotPermission = permission;
119-
_isLoading = false;
120-
});
116+
_checkLocationStatus().then((status) {
117+
setState(() {
118+
_locationStatus = status;
119+
_gotPermission = permission;
120+
_isLoading = false;
121121
});
122+
});
122123
});
123124
}
124125
});
@@ -133,20 +134,31 @@ class _NearMeState extends State<NearMePage> {
133134
});
134135
if (status) {
135136
fetchNearStops().then((value) {
136-
setState(() {
137-
nearStops.clear();
138-
nearStops.addAll(value);
139-
_isLoadingNew = false;
137+
print(value.length);
138+
if (value.length == 0) {
139+
print('Unable to fetch!');
140+
setState(() {
141+
_error = true;
140142
_isLoading = false;
141-
getApplicationDocumentsDirectory()
142-
.then((Directory directory) {
143-
File file =
144-
new File(directory.path + "/" + nearStopsFileName);
145-
file.createSync();
146-
file.writeAsStringSync(json.encode(nearStops));
147-
print('nearStops saved');
143+
_isLoadingNew = false;
148144
});
149-
});
145+
} else {
146+
setState(() {
147+
nearStops.clear();
148+
nearStops.addAll(value);
149+
_error = false;
150+
_isLoadingNew = false;
151+
_isLoading = false;
152+
getApplicationDocumentsDirectory()
153+
.then((Directory directory) {
154+
File file =
155+
new File(directory.path + "/" + nearStopsFileName);
156+
file.createSync();
157+
file.writeAsStringSync(json.encode(nearStops));
158+
print('nearStops saved');
159+
});
160+
});
161+
}
150162
});
151163
} else {
152164
setState(() {
@@ -213,7 +225,7 @@ class _NearMeState extends State<NearMePage> {
213225
currentLocation.latitude.toString() +
214226
'&long=' +
215227
currentLocation.longitude.toString() +
216-
'&skin=' +
228+
'&skin=' +
217229
tableThemeInt.toString();
218230
var response = await http.get(url);
219231

@@ -253,25 +265,42 @@ class _NearMeState extends State<NearMePage> {
253265
child: _isLoading
254266
? Center()
255267
: _locationStatus
256-
? Scrollbar(
257-
child: ListView.builder(
258-
scrollDirection: Axis.vertical,
259-
itemCount: nearStops.length,
260-
itemBuilder: (context, index) {
261-
return new FlatButton(
262-
child: NearStopRow(nearStops[index]),
263-
onPressed: () {
264-
Navigator.push(
265-
context,
266-
new MaterialPageRoute(
267-
builder: (context) =>
268-
new StopWebView(
269-
nearStops[index])));
268+
? _error
269+
? Padding(
270+
padding: EdgeInsets.only(top: 250.0),
271+
child: Center(
272+
child: Column(
273+
children: <Widget>[
274+
Icon(Icons.warning,
275+
size: 150.0,
276+
color: Colors.grey[300]),
277+
Text(
278+
'Currently unavailable, try again later!',
279+
style: TextStyle(
280+
color: Colors.grey[500]))
281+
],
282+
),
283+
),
284+
)
285+
: Scrollbar(
286+
child: ListView.builder(
287+
scrollDirection: Axis.vertical,
288+
itemCount: nearStops.length,
289+
itemBuilder: (context, index) {
290+
return new FlatButton(
291+
child: NearStopRow(nearStops[index]),
292+
onPressed: () {
293+
Navigator.push(
294+
context,
295+
new MaterialPageRoute(
296+
builder: (context) =>
297+
new StopWebView(
298+
nearStops[index])));
299+
},
300+
);
270301
},
271-
);
272-
},
273-
),
274-
)
302+
),
303+
)
275304
: Padding(
276305
padding: EdgeInsets.only(top: 250.0),
277306
child: Center(
@@ -280,7 +309,7 @@ class _NearMeState extends State<NearMePage> {
280309
? <Widget>[
281310
Icon(
282311
Icons.not_interested,
283-
size: 200.0,
312+
size: 150.0,
284313
color: Colors.grey[300],
285314
),
286315
Text(
@@ -292,7 +321,7 @@ class _NearMeState extends State<NearMePage> {
292321
: <Widget>[
293322
Icon(
294323
Icons.location_off,
295-
size: 200.0,
324+
size: 150.0,
296325
color: Colors.grey[300],
297326
),
298327
_gotPermission
@@ -331,7 +360,7 @@ class _NearMeState extends State<NearMePage> {
331360
children: <Widget>[
332361
Icon(
333362
Icons.signal_cellular_off,
334-
size: 200.0,
363+
size: 150.0,
335364
color: Colors.grey[300],
336365
),
337366
Text(

lib/TripPlanner.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ class _TripPlannerState extends State<TripPlannerPage> {
176176
appBar: AppBar(
177177
centerTitle: true,
178178
title: Text('Trip planner'),
179-
backgroundColor: primaryColor,
180179
actions: <Widget>[
181180
IconButton(
182181
icon: Icon(Icons.more_vert),
@@ -191,7 +190,7 @@ class _TripPlannerState extends State<TripPlannerPage> {
191190
)
192191
],
193192
bottom: PreferredSize(
194-
preferredSize: Size.fromHeight(188.0),
193+
preferredSize: Size.fromHeight(186.0),
195194
child: _inputBar(),
196195
),
197196
),
@@ -201,7 +200,7 @@ class _TripPlannerState extends State<TripPlannerPage> {
201200
child: Column(
202201
children: <Widget>[
203202
Padding(padding: EdgeInsets.all(40.0),),
204-
Icon(Icons.search, size: 200.0, color: Colors.grey[300]),
203+
Icon(Icons.search, size: 150.0, color: Colors.grey[300]),
205204
Text("Plan your journy via public transport!",
206205
style: TextStyle(color: Colors.grey[500]))
207206
],
@@ -270,7 +269,7 @@ class _TripPlannerState extends State<TripPlannerPage> {
270269
: "Train",
271270
style: TextStyle(
272271
fontWeight: FontWeight.bold,
273-
fontSize: 16.0,
272+
fontSize: 20.0,
274273
color: Colors.white))),
275274
),
276275
),
@@ -347,7 +346,7 @@ class _TripPlannerState extends State<TripPlannerPage> {
347346
_inputBar() {
348347
return Padding(
349348
padding: const EdgeInsets.only(
350-
bottom: 20.0, left: 15.0, right: 15.0, top: 0.0),
349+
bottom: 5.0, left: 15.0, right: 15.0, top: 0.0),
351350
child: Column(
352351
children: <Widget>[
353352
Row(
@@ -494,10 +493,12 @@ class _TripPlannerState extends State<TripPlannerPage> {
494493
child: Row(
495494
children: <Widget>[
496495
Flexible(
497-
child: Row(
496+
child: Column(
497+
498498
children: <Widget>[
499499
FlatButton(
500500
padding: EdgeInsets.all(0),
501+
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
501502
onPressed: () {
502503
setState(() {
503504
arrivalDeparature = false;
@@ -523,6 +524,7 @@ class _TripPlannerState extends State<TripPlannerPage> {
523524
),
524525
FlatButton(
525526
padding: EdgeInsets.all(0),
527+
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
526528
onPressed: () {
527529
setState(() {
528530
arrivalDeparature = true;

lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import 'widgets/stopList.dart';
2222
import 'locale/locales.dart';
2323

2424
void main() async {
25-
await WidgetsFlutterBinding.ensureInitialized();
25+
WidgetsFlutterBinding.ensureInitialized();
2626
await PrefService.init(prefix: 'pref_');
2727
runApp(AlertProvider(
2828
child: MyApp(),
@@ -52,7 +52,7 @@ final _model = ThemeModel(
5252
buttonColor: Colors.red,
5353
),
5454
customBlackTheme: ThemeData(
55-
primaryColor: primaryColor, //can be black
55+
primaryColor: Colors.black, //can be Colors.grey[90]
5656
accentColor: Colors.red,
5757
brightness: Brightness.dark,
5858
backgroundColor: Colors.black,

0 commit comments

Comments
 (0)