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

Commit

Permalink
fixed Trip planner
Browse files Browse the repository at this point in the history
  • Loading branch information
magicsk committed Mar 27, 2020
1 parent 9092182 commit 8b20b3f
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 51 deletions.
6 changes: 3 additions & 3 deletions ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=C:\Users\magic_sk\Downloads\dev\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Users\magic_sk\Downloads\dev\mhd_virtual_table"
export "FLUTTER_ROOT=C:\Users\magic_sk\Development\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Users\magic_sk\Development\mhd_virtual_table"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
export "FLUTTER_FRAMEWORK_DIR=C:\Users\magic_sk\Downloads\dev\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_FRAMEWORK_DIR=C:\Users\magic_sk\Development\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1.0.0"
109 changes: 69 additions & 40 deletions lib/NearMe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class _NearMeState extends State<NearMePage> {
bool _locationStatus = false;
bool _networkStatus = false;
bool _restricted = false;
bool _error = false;
int tableThemeInt;

_getprefs() async {
Expand Down Expand Up @@ -112,13 +113,13 @@ class _NearMeState extends State<NearMePage> {
nearStops.addAll(_nearStopsFile);
print('nearStops loaded');
_getprefs().then((permission) {
_checkLocationStatus().then((status) {
setState(() {
_locationStatus = status;
_gotPermission = permission;
_isLoading = false;
});
_checkLocationStatus().then((status) {
setState(() {
_locationStatus = status;
_gotPermission = permission;
_isLoading = false;
});
});
});
}
});
Expand All @@ -133,20 +134,31 @@ class _NearMeState extends State<NearMePage> {
});
if (status) {
fetchNearStops().then((value) {
setState(() {
nearStops.clear();
nearStops.addAll(value);
_isLoadingNew = false;
print(value.length);
if (value.length == 0) {
print('Unable to fetch!');
setState(() {
_error = true;
_isLoading = false;
getApplicationDocumentsDirectory()
.then((Directory directory) {
File file =
new File(directory.path + "/" + nearStopsFileName);
file.createSync();
file.writeAsStringSync(json.encode(nearStops));
print('nearStops saved');
_isLoadingNew = false;
});
});
} else {
setState(() {
nearStops.clear();
nearStops.addAll(value);
_error = false;
_isLoadingNew = false;
_isLoading = false;
getApplicationDocumentsDirectory()
.then((Directory directory) {
File file =
new File(directory.path + "/" + nearStopsFileName);
file.createSync();
file.writeAsStringSync(json.encode(nearStops));
print('nearStops saved');
});
});
}
});
} else {
setState(() {
Expand Down Expand Up @@ -213,7 +225,7 @@ class _NearMeState extends State<NearMePage> {
currentLocation.latitude.toString() +
'&long=' +
currentLocation.longitude.toString() +
'&skin=' +
'&skin=' +
tableThemeInt.toString();
var response = await http.get(url);

Expand Down Expand Up @@ -253,25 +265,42 @@ class _NearMeState extends State<NearMePage> {
child: _isLoading
? Center()
: _locationStatus
? Scrollbar(
child: ListView.builder(
scrollDirection: Axis.vertical,
itemCount: nearStops.length,
itemBuilder: (context, index) {
return new FlatButton(
child: NearStopRow(nearStops[index]),
onPressed: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) =>
new StopWebView(
nearStops[index])));
? _error
? Padding(
padding: EdgeInsets.only(top: 250.0),
child: Center(
child: Column(
children: <Widget>[
Icon(Icons.warning,
size: 150.0,
color: Colors.grey[300]),
Text(
'Currently unavailable, try again later!',
style: TextStyle(
color: Colors.grey[500]))
],
),
),
)
: Scrollbar(
child: ListView.builder(
scrollDirection: Axis.vertical,
itemCount: nearStops.length,
itemBuilder: (context, index) {
return new FlatButton(
child: NearStopRow(nearStops[index]),
onPressed: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) =>
new StopWebView(
nearStops[index])));
},
);
},
);
},
),
)
),
)
: Padding(
padding: EdgeInsets.only(top: 250.0),
child: Center(
Expand All @@ -280,7 +309,7 @@ class _NearMeState extends State<NearMePage> {
? <Widget>[
Icon(
Icons.not_interested,
size: 200.0,
size: 150.0,
color: Colors.grey[300],
),
Text(
Expand All @@ -292,7 +321,7 @@ class _NearMeState extends State<NearMePage> {
: <Widget>[
Icon(
Icons.location_off,
size: 200.0,
size: 150.0,
color: Colors.grey[300],
),
_gotPermission
Expand Down Expand Up @@ -331,7 +360,7 @@ class _NearMeState extends State<NearMePage> {
children: <Widget>[
Icon(
Icons.signal_cellular_off,
size: 200.0,
size: 150.0,
color: Colors.grey[300],
),
Text(
Expand Down
14 changes: 8 additions & 6 deletions lib/TripPlanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ class _TripPlannerState extends State<TripPlannerPage> {
appBar: AppBar(
centerTitle: true,
title: Text('Trip planner'),
backgroundColor: primaryColor,
actions: <Widget>[
IconButton(
icon: Icon(Icons.more_vert),
Expand All @@ -191,7 +190,7 @@ class _TripPlannerState extends State<TripPlannerPage> {
)
],
bottom: PreferredSize(
preferredSize: Size.fromHeight(188.0),
preferredSize: Size.fromHeight(186.0),
child: _inputBar(),
),
),
Expand All @@ -201,7 +200,7 @@ class _TripPlannerState extends State<TripPlannerPage> {
child: Column(
children: <Widget>[
Padding(padding: EdgeInsets.all(40.0),),
Icon(Icons.search, size: 200.0, color: Colors.grey[300]),
Icon(Icons.search, size: 150.0, color: Colors.grey[300]),
Text("Plan your journy via public transport!",
style: TextStyle(color: Colors.grey[500]))
],
Expand Down Expand Up @@ -270,7 +269,7 @@ class _TripPlannerState extends State<TripPlannerPage> {
: "Train",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16.0,
fontSize: 20.0,
color: Colors.white))),
),
),
Expand Down Expand Up @@ -347,7 +346,7 @@ class _TripPlannerState extends State<TripPlannerPage> {
_inputBar() {
return Padding(
padding: const EdgeInsets.only(
bottom: 20.0, left: 15.0, right: 15.0, top: 0.0),
bottom: 5.0, left: 15.0, right: 15.0, top: 0.0),
child: Column(
children: <Widget>[
Row(
Expand Down Expand Up @@ -494,10 +493,12 @@ class _TripPlannerState extends State<TripPlannerPage> {
child: Row(
children: <Widget>[
Flexible(
child: Row(
child: Column(

children: <Widget>[
FlatButton(
padding: EdgeInsets.all(0),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () {
setState(() {
arrivalDeparature = false;
Expand All @@ -523,6 +524,7 @@ class _TripPlannerState extends State<TripPlannerPage> {
),
FlatButton(
padding: EdgeInsets.all(0),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () {
setState(() {
arrivalDeparature = true;
Expand Down
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import 'widgets/stopList.dart';
import 'locale/locales.dart';

void main() async {
await WidgetsFlutterBinding.ensureInitialized();
WidgetsFlutterBinding.ensureInitialized();
await PrefService.init(prefix: 'pref_');
runApp(AlertProvider(
child: MyApp(),
Expand Down Expand Up @@ -52,7 +52,7 @@ final _model = ThemeModel(
buttonColor: Colors.red,
),
customBlackTheme: ThemeData(
primaryColor: primaryColor, //can be black
primaryColor: Colors.black, //can be Colors.grey[90]
accentColor: Colors.red,
brightness: Brightness.dark,
backgroundColor: Colors.black,
Expand Down

0 comments on commit 8b20b3f

Please sign in to comment.