fixed gps page
This commit is contained in:
@ -499,6 +499,22 @@ class DestinationController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addGPStoDB(double la, double ln, {isCheckin = 0}) async {
|
||||
GpsDatabaseHelper db = GpsDatabaseHelper.instance;
|
||||
final team_name = indexController.currentUser[0]["user"]['team_name'];
|
||||
final event_code = indexController.currentUser[0]["user"]["event_code"];
|
||||
GpsData gps_data = GpsData(
|
||||
id: 0,
|
||||
team_name: team_name,
|
||||
event_code: event_code,
|
||||
lat: la,
|
||||
lon: ln,
|
||||
is_checkin: isCheckin,
|
||||
created_at: DateTime.now().microsecondsSinceEpoch);
|
||||
var res = await db.insertGps(gps_data);
|
||||
print("==gps res == ${res}");
|
||||
}
|
||||
|
||||
Future<void> checkForCheckin() async {
|
||||
print("--- Start of checkForCheckin function ---");
|
||||
|
||||
@ -512,21 +528,22 @@ class DestinationController extends GetxController {
|
||||
final la = position.latitude;
|
||||
final ln = position.longitude;
|
||||
|
||||
print("--- gps is ${la}, ${ln}");
|
||||
//print("--- gps is ${la}, ${ln}");
|
||||
|
||||
//add gps to database
|
||||
GpsDatabaseHelper db = GpsDatabaseHelper.instance;
|
||||
final team_name = indexController.currentUser[0]["user"]['team_name'];
|
||||
final event_code = indexController.currentUser[0]["user"]["event_code"];
|
||||
print("--- curr gps is ${la}, ${ln}");
|
||||
GpsData gps_data = GpsData(
|
||||
id: 0,
|
||||
team_name: team_name,
|
||||
event_code: event_code,
|
||||
lat: la,
|
||||
lon: ln,
|
||||
created_at: DateTime.now().microsecondsSinceEpoch);
|
||||
await db.insertGps(gps_data);
|
||||
await addGPStoDB(la, ln);
|
||||
// GpsDatabaseHelper db = GpsDatabaseHelper.instance;
|
||||
// final team_name = indexController.currentUser[0]["user"]['team_name'];
|
||||
// final event_code = indexController.currentUser[0]["user"]["event_code"];
|
||||
// print("--- curr gps is ${la}, ${ln}");
|
||||
// GpsData gps_data = GpsData(
|
||||
// id: 0,
|
||||
// team_name: team_name,
|
||||
// event_code: event_code,
|
||||
// lat: la,
|
||||
// lon: ln,
|
||||
// created_at: DateTime.now().microsecondsSinceEpoch);
|
||||
// await db.insertGps(gps_data);
|
||||
|
||||
for (GeoJsonFeature fs in indexController.locations[0].collection) {
|
||||
GeoJsonMultiPoint mp = fs.geometry as GeoJsonMultiPoint;
|
||||
@ -648,6 +665,8 @@ class DestinationController extends GetxController {
|
||||
DateTime now = DateTime.now();
|
||||
String formattedDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(now);
|
||||
|
||||
await addGPStoDB(destination.lat!, destination.lon!, isCheckin: 1);
|
||||
|
||||
// print("------ checkin event $eventCode ------");
|
||||
ExternalService()
|
||||
.makeCheckpoint(userId, token, formattedDate, team, cpNum.round(),
|
||||
@ -658,6 +677,10 @@ class DestinationController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> removeCheckin(int cp) {
|
||||
return ExternalService().removeCheckin(cp);
|
||||
}
|
||||
|
||||
Future<void> startGame() async {
|
||||
//print("------ starting game ------");
|
||||
await checkForCheckin();
|
||||
|
||||
Reference in New Issue
Block a user