|
|
|
|
@ -37,7 +37,8 @@ class DestinationController extends GetxController {
|
|
|
|
|
double currentLat = 0.0;
|
|
|
|
|
double currentLon = 0.0;
|
|
|
|
|
|
|
|
|
|
bool gps_push_started = false;
|
|
|
|
|
static bool gps_push_started = false;
|
|
|
|
|
static bool game_started = false;
|
|
|
|
|
|
|
|
|
|
bool skip_10s = false;
|
|
|
|
|
|
|
|
|
|
@ -125,7 +126,7 @@ class DestinationController extends GetxController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> startTimer(Destination d, double distance) async {
|
|
|
|
|
print("=== passed dest is ${d.location_id} ${d.checkedin} ====");
|
|
|
|
|
//print("=== passed dest is ${d.location_id} ${d.checkedin} ====");
|
|
|
|
|
skipGps = true;
|
|
|
|
|
//print("---- in startTimer ----");
|
|
|
|
|
|
|
|
|
|
@ -514,11 +515,12 @@ class DestinationController extends GetxController {
|
|
|
|
|
is_checkin: isCheckin,
|
|
|
|
|
created_at: DateTime.now().millisecondsSinceEpoch);
|
|
|
|
|
var res = await db.insertGps(gps_data);
|
|
|
|
|
print("==gps res == ${res}");
|
|
|
|
|
//print("==gps res == ${res}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> checkForCheckin() async {
|
|
|
|
|
print("--- Start of checkForCheckin function ---");
|
|
|
|
|
//print("--- Start of checkForCheckin function ---");
|
|
|
|
|
game_started = true;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
//print("--- 000 ---- $skip_gps----");
|
|
|
|
|
@ -587,15 +589,17 @@ class DestinationController extends GetxController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> pushGPStoServer() async {
|
|
|
|
|
// print(
|
|
|
|
|
// "^^^^^^^^ ${DateFormat('kk:mm:ss \n EEE d MMM').format(DateTime.now())}");
|
|
|
|
|
try {
|
|
|
|
|
await Future.delayed(const Duration(minutes: 5));
|
|
|
|
|
gps_push_started = true;
|
|
|
|
|
ExternalService().pushGPS();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
//print("An error occurred: $e");
|
|
|
|
|
await pushGPStoServer();
|
|
|
|
|
//await pushGPStoServer();
|
|
|
|
|
} finally {
|
|
|
|
|
//print("--- End of pushGPStoServer function, calling recursively ---");
|
|
|
|
|
await Future.delayed(const Duration(seconds: 5 * 60));
|
|
|
|
|
await pushGPStoServer();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -702,7 +706,9 @@ class DestinationController extends GetxController {
|
|
|
|
|
|
|
|
|
|
Future<void> startGame() async {
|
|
|
|
|
//print("------ starting game ------");
|
|
|
|
|
await checkForCheckin();
|
|
|
|
|
if (game_started == false) {
|
|
|
|
|
await checkForCheckin();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -718,13 +724,13 @@ class DestinationController extends GetxController {
|
|
|
|
|
|
|
|
|
|
Destination des = festuretoDestination(gfs);
|
|
|
|
|
|
|
|
|
|
print("=== gfs == ${des.toMap()}");
|
|
|
|
|
//print("=== gfs == ${des.toMap()}");
|
|
|
|
|
|
|
|
|
|
double distanceToDest = double.infinity;
|
|
|
|
|
var distance = const Distance();
|
|
|
|
|
distanceToDest = distance.as(LengthUnit.Meter,
|
|
|
|
|
LatLng(currentLat, currentLon), LatLng(des.lat!, des.lon!));
|
|
|
|
|
print("==== dist==${distanceToDest}");
|
|
|
|
|
//print("==== dist==${distanceToDest}");
|
|
|
|
|
return distanceToDest;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -744,7 +750,7 @@ class DestinationController extends GetxController {
|
|
|
|
|
if (distanceToDest <= 500) {
|
|
|
|
|
return 500;
|
|
|
|
|
}
|
|
|
|
|
print("==== forced dist ==${distanceToDest}");
|
|
|
|
|
//print("==== forced dist ==${distanceToDest}");
|
|
|
|
|
return _retValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|