|
|
|
|
@ -113,7 +113,7 @@ class DestinationController extends GetxController {
|
|
|
|
|
print("---- is in rog is ${is_in_rog} ----");
|
|
|
|
|
//skip_gps = true;
|
|
|
|
|
double checkinRadious = fs.properties!['checkin_radius'] ?? double.infinity;
|
|
|
|
|
//if (checkinRadious >= distance) {
|
|
|
|
|
if (checkinRadious >= distance) {
|
|
|
|
|
indexController.currentFeature.clear();
|
|
|
|
|
Destination d = festuretoDestination(fs);
|
|
|
|
|
print("----- destination lenght is ${destinations.length} -----");
|
|
|
|
|
@ -126,7 +126,8 @@ class DestinationController extends GetxController {
|
|
|
|
|
indexController.currentFeature.add(fs);
|
|
|
|
|
print("---- before calling startTimer ----");
|
|
|
|
|
startTimer(d, distance);
|
|
|
|
|
//}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void startTimer(Destination d, double distance) async {
|
|
|
|
|
@ -139,7 +140,8 @@ class DestinationController extends GetxController {
|
|
|
|
|
|
|
|
|
|
double checkinRadious = d.checkin_radious ?? double.infinity;
|
|
|
|
|
bool autoCheckin = d.auto_checkin == 0 ? false : true;
|
|
|
|
|
bool locationAlreadyCheckedIn = ds.length > 0 && ds[0].checkedin == true ? true : false;
|
|
|
|
|
bool locationAlreadyCheckedIn =
|
|
|
|
|
ds.length > 0 && ds[0].checkedin == true ? true : false;
|
|
|
|
|
bool isuserLoggedIn = indexController.currentUser.isNotEmpty ? true : false;
|
|
|
|
|
//make current destination
|
|
|
|
|
print("---- checkin_radious $checkinRadious ----");
|
|
|
|
|
@ -159,9 +161,7 @@ class DestinationController extends GetxController {
|
|
|
|
|
if (is_photo_shoot.value == true) {
|
|
|
|
|
photos.clear();
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
constraints: BoxConstraints.loose(Size(
|
|
|
|
|
Get.width,
|
|
|
|
|
Get.height * 0.75)),
|
|
|
|
|
constraints: BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
|
|
|
|
context: Get.context!,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
builder: ((context) => CameraPage())).whenComplete(() {
|
|
|
|
|
@ -182,9 +182,8 @@ class DestinationController extends GetxController {
|
|
|
|
|
is_in_checkin.value = true;
|
|
|
|
|
is_at_start.value = true;
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
constraints: BoxConstraints.loose(Size(
|
|
|
|
|
Get.width,
|
|
|
|
|
Get.height * 0.75)),
|
|
|
|
|
constraints:
|
|
|
|
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
|
|
|
|
context: Get.context!,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
builder: ((context) => BottomSheetNew())).whenComplete(() {
|
|
|
|
|
@ -198,9 +197,8 @@ class DestinationController extends GetxController {
|
|
|
|
|
chekcs = 2;
|
|
|
|
|
is_in_checkin.value = true;
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
constraints: BoxConstraints.loose(Size(
|
|
|
|
|
Get.width,
|
|
|
|
|
Get.height * 0.75)),
|
|
|
|
|
constraints:
|
|
|
|
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
|
|
|
|
context: Get.context!,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
builder: ((context) => BottomSheetNew())).whenComplete(() {
|
|
|
|
|
@ -237,9 +235,8 @@ class DestinationController extends GetxController {
|
|
|
|
|
is_in_checkin.value = true;
|
|
|
|
|
photos.clear();
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
constraints: BoxConstraints.loose(Size(
|
|
|
|
|
Get.width,
|
|
|
|
|
Get.height * 0.75)),
|
|
|
|
|
constraints:
|
|
|
|
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
|
|
|
|
context: Get.context!,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
builder: ((context) => CameraPage(
|
|
|
|
|
@ -290,9 +287,8 @@ class DestinationController extends GetxController {
|
|
|
|
|
is_at_goal.value = true;
|
|
|
|
|
photos.clear();
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
constraints: BoxConstraints.loose(Size(
|
|
|
|
|
Get.width,
|
|
|
|
|
Get.height * 0.75)),
|
|
|
|
|
constraints:
|
|
|
|
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
|
|
|
|
context: Get.context!,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
builder: ((context) => CameraPage(
|
|
|
|
|
@ -310,9 +306,8 @@ class DestinationController extends GetxController {
|
|
|
|
|
chekcs = 6;
|
|
|
|
|
is_at_start.value = true;
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
constraints: BoxConstraints.loose(Size(
|
|
|
|
|
Get.width,
|
|
|
|
|
Get.height * 0.75)),
|
|
|
|
|
constraints:
|
|
|
|
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
|
|
|
|
context: Get.context!,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
builder: ((context) => BottomSheetNew())).whenComplete(() {
|
|
|
|
|
@ -327,6 +322,7 @@ class DestinationController extends GetxController {
|
|
|
|
|
if (chekcs == 0) {
|
|
|
|
|
skip_gps = false;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void resetRogaining() async {
|
|
|
|
|
@ -355,6 +351,7 @@ class DestinationController extends GetxController {
|
|
|
|
|
db.deleteAllDestinations().then((value) {
|
|
|
|
|
PopulateDestinations();
|
|
|
|
|
startGPSTimer();
|
|
|
|
|
startGame();
|
|
|
|
|
//initGPS();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@ -376,9 +373,7 @@ class DestinationController extends GetxController {
|
|
|
|
|
print("----image file is : $file----");
|
|
|
|
|
//setState(() {});
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
));
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getRoutePoints() {
|
|
|
|
|
@ -424,9 +419,8 @@ class DestinationController extends GetxController {
|
|
|
|
|
is_in_checkin.value = true;
|
|
|
|
|
photos.clear();
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
constraints: BoxConstraints.loose(Size(
|
|
|
|
|
Get.width,
|
|
|
|
|
Get.height * 0.75)),
|
|
|
|
|
constraints:
|
|
|
|
|
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
|
|
|
|
context: Get.context!,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
builder: ((context) => CameraPage(
|
|
|
|
|
@ -443,39 +437,14 @@ class DestinationController extends GetxController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void checkForCheckin(double la, double ln) {
|
|
|
|
|
print("--- skip_gps ---- $skip_gps----");
|
|
|
|
|
void checkForCheckin() async {
|
|
|
|
|
print("--- Start of checkForCheckin function ---");
|
|
|
|
|
|
|
|
|
|
// for (final d in destinations) {
|
|
|
|
|
// print("--- check checkin for--loc_id- ${d.sub_loc_id}----");
|
|
|
|
|
|
|
|
|
|
// double lat = d.lat!;
|
|
|
|
|
// double lon = d.lon!;
|
|
|
|
|
// LatLng p = LatLng(lat, lon);
|
|
|
|
|
// getDestinationForLatLong(lat, lon).then((value) {
|
|
|
|
|
// var distance = const Distance();
|
|
|
|
|
// double dist =
|
|
|
|
|
// distance.as(LengthUnit.Meter, LatLng(lat, lon), LatLng(la, ln));
|
|
|
|
|
// //double checkin_radious = value!.checkin_radious ?? double.infinity;
|
|
|
|
|
// //bool auto_checkin = value.auto_checkin == 0 ? false : true;
|
|
|
|
|
// //bool location_already_checked_id = d.checkedin ?? false;
|
|
|
|
|
|
|
|
|
|
// // print("-----rogaining_counted---${rogaining_counted.value}-----");
|
|
|
|
|
// // print("-----is_in_rog---${is_in_rog}-----");
|
|
|
|
|
// // print("-----dist is ---${dist}-----");
|
|
|
|
|
// //print("----- ${indexController.currentUser} ----");
|
|
|
|
|
|
|
|
|
|
// if (dist <= 250 && skip_gps == false) {
|
|
|
|
|
// //near a destination
|
|
|
|
|
// print("---- time with ${d.location_id} ----");
|
|
|
|
|
// startTimer(d, dist);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if (indexController.locations.isEmpty) return;
|
|
|
|
|
|
|
|
|
|
//check for location in bounds
|
|
|
|
|
try {
|
|
|
|
|
print("--- 000 ---- $skip_gps----");
|
|
|
|
|
await Future.delayed(const Duration(milliseconds: 1500));
|
|
|
|
|
final la = current_lat;
|
|
|
|
|
final ln = current_lon;
|
|
|
|
|
for (GeoJsonFeature fs in indexController.locations[0].collection) {
|
|
|
|
|
GeoJsonMultiPoint mp = fs.geometry as GeoJsonMultiPoint;
|
|
|
|
|
LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude,
|
|
|
|
|
@ -483,18 +452,71 @@ class DestinationController extends GetxController {
|
|
|
|
|
|
|
|
|
|
double latFs = pt.latitude;
|
|
|
|
|
double lonFs = pt.longitude;
|
|
|
|
|
LatLng pFs = LatLng(latFs, lonFs);
|
|
|
|
|
var distanceFs = const Distance();
|
|
|
|
|
double distFs =
|
|
|
|
|
distanceFs.as(LengthUnit.Meter, LatLng(latFs, lonFs), LatLng(la, ln));
|
|
|
|
|
double distFs = distanceFs.as(
|
|
|
|
|
LengthUnit.Meter, LatLng(latFs, lonFs), LatLng(la, ln));
|
|
|
|
|
|
|
|
|
|
if (distFs <= 250 && skip_gps == false) {
|
|
|
|
|
print("--- 789 ---- $skip_gps----");
|
|
|
|
|
//near a location
|
|
|
|
|
print("---- before call startTimerLocation ----");
|
|
|
|
|
startTimerLocation(fs, distFs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
print("--- 123 ---- $skip_gps----");
|
|
|
|
|
} catch (e) {
|
|
|
|
|
print("An error occurred: $e");
|
|
|
|
|
} finally {
|
|
|
|
|
print("--- End of checkForCheckin function, calling recursively ---");
|
|
|
|
|
checkForCheckin();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// void checkForCheckin() async {
|
|
|
|
|
// final la = current_lat;
|
|
|
|
|
// final ln = current_lon;
|
|
|
|
|
|
|
|
|
|
// print("--- in checkForCheckin ----");
|
|
|
|
|
// // if (indexController.locations.isEmpty){
|
|
|
|
|
// // await Future.delayed(const Duration(seconds: 2));
|
|
|
|
|
// // checkForCheckin();
|
|
|
|
|
// // return;
|
|
|
|
|
// // }
|
|
|
|
|
|
|
|
|
|
// print("--- 123 ---- $skip_gps----");
|
|
|
|
|
|
|
|
|
|
// //check for location in bounds
|
|
|
|
|
// for (GeoJsonFeature fs in indexController.locations[0].collection) {
|
|
|
|
|
// try {
|
|
|
|
|
// await Future.delayed(const Duration(seconds: 2000));
|
|
|
|
|
// GeoJsonMultiPoint mp = fs.geometry as GeoJsonMultiPoint;
|
|
|
|
|
// LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude,
|
|
|
|
|
// mp.geoSerie!.geoPoints[0].longitude);
|
|
|
|
|
|
|
|
|
|
// print("--- 456 ---- $skip_gps----");
|
|
|
|
|
|
|
|
|
|
// double latFs = pt.latitude;
|
|
|
|
|
// double lonFs = pt.longitude;
|
|
|
|
|
// LatLng pFs = LatLng(latFs, lonFs);
|
|
|
|
|
// var distanceFs = const Distance();
|
|
|
|
|
// double distFs = distanceFs.as(
|
|
|
|
|
// LengthUnit.Meter, LatLng(latFs, lonFs), LatLng(la, ln));
|
|
|
|
|
|
|
|
|
|
// if (distFs <= 250 && skip_gps == false) {
|
|
|
|
|
// print("--- 789 ---- $skip_gps----");
|
|
|
|
|
// //near a location
|
|
|
|
|
// print("---- before call startTimerLocation ----");
|
|
|
|
|
// startTimerLocation(fs, distFs);
|
|
|
|
|
// }
|
|
|
|
|
// } catch (e) {
|
|
|
|
|
// print("----- error -----");
|
|
|
|
|
// } finally {
|
|
|
|
|
// print("--- 101112 ----");
|
|
|
|
|
// checkForCheckin();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// //await Future.delayed(const Duration(seconds: 3));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
void addToRogaining(double lat, double lon, int destinationId) async {
|
|
|
|
|
DatabaseHelper db = DatabaseHelper.instance;
|
|
|
|
|
@ -588,7 +610,8 @@ class DestinationController extends GetxController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
positionStream = Geolocator.getPositionStream(locationSettings: locationSettings)
|
|
|
|
|
positionStream =
|
|
|
|
|
Geolocator.getPositionStream(locationSettings: locationSettings)
|
|
|
|
|
.listen((Position? position) {
|
|
|
|
|
current_lat = position != null ? position.latitude : 0;
|
|
|
|
|
current_lon = position != null ? position.longitude : 0;
|
|
|
|
|
@ -609,7 +632,7 @@ class DestinationController extends GetxController {
|
|
|
|
|
//gps.clear();
|
|
|
|
|
//gps.add(
|
|
|
|
|
// "-- lat : ${position.latitude}, lon : ${position.longitude} --");
|
|
|
|
|
checkForCheckin(position.latitude, position.longitude);
|
|
|
|
|
//checkForCheckin(position.latitude, position.longitude);
|
|
|
|
|
print("--- call check checkin");
|
|
|
|
|
print("---- skip gps is ${skip_gps.toString()} ----");
|
|
|
|
|
//});
|
|
|
|
|
@ -624,14 +647,14 @@ class DestinationController extends GetxController {
|
|
|
|
|
ever(indexController.connectionStatusName, connectionChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void startGPSTimer() {
|
|
|
|
|
// If a timer is already running, we first cancel it
|
|
|
|
|
_GPStimer?.cancel();
|
|
|
|
|
|
|
|
|
|
// Start a new timer that fires every 3 seconds
|
|
|
|
|
_timer = Timer.periodic(Duration(seconds: 3), (timer) async {
|
|
|
|
|
Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
|
|
|
|
|
Position position = await Geolocator.getCurrentPosition(
|
|
|
|
|
desiredAccuracy: LocationAccuracy.high);
|
|
|
|
|
current_lat = position.latitude;
|
|
|
|
|
current_lon = position.longitude;
|
|
|
|
|
|
|
|
|
|
@ -639,7 +662,7 @@ class DestinationController extends GetxController {
|
|
|
|
|
double czoom = indexController.rogMapController.zoom;
|
|
|
|
|
indexController.rogMapController
|
|
|
|
|
.move(LatLng(position.latitude, position.longitude), czoom);
|
|
|
|
|
checkForCheckin(position.latitude, position.longitude);
|
|
|
|
|
//checkForCheckin(position.latitude, position.longitude);
|
|
|
|
|
print("--- call check checkin");
|
|
|
|
|
print("---- skip gps is ${skip_gps.toString()} ----");
|
|
|
|
|
}
|
|
|
|
|
@ -650,7 +673,9 @@ class DestinationController extends GetxController {
|
|
|
|
|
_GPStimer?.cancel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void startGame() {
|
|
|
|
|
checkForCheckin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void onClose() {
|
|
|
|
|
@ -664,6 +689,7 @@ class DestinationController extends GetxController {
|
|
|
|
|
void onInit() async {
|
|
|
|
|
//initGPS();
|
|
|
|
|
startGPSTimer();
|
|
|
|
|
startGame();
|
|
|
|
|
super.onInit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|