added buypoint images
This commit is contained in:
@ -108,7 +108,7 @@ class DestinationController extends GetxController {
|
||||
hidden_location: fs.properties!["hidden_location"] == true ? 1 : 0);
|
||||
}
|
||||
|
||||
void startTimerLocation(GeoJsonFeature fs, double distance) {
|
||||
Future<void> startTimerLocation(GeoJsonFeature fs, double distance) async {
|
||||
print("---- in startTimer ----");
|
||||
print("---- is in rog is ${is_in_rog} ----");
|
||||
//skip_gps = true;
|
||||
@ -125,21 +125,27 @@ class DestinationController extends GetxController {
|
||||
// }
|
||||
indexController.currentFeature.add(fs);
|
||||
print("---- before calling startTimer ----");
|
||||
startTimer(d, distance);
|
||||
await startTimer(d, distance);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void startTimer(Destination d, double distance) async {
|
||||
Future<void> startTimer(Destination d, double distance) async {
|
||||
print("=== passed dest is ${d.location_id} ${d.checkedin} ====");
|
||||
skip_gps = true;
|
||||
//skip_gps = true;
|
||||
print("---- in startTimer ----");
|
||||
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
List<Destination> ds = await db.getDestinationByLatLon(d.lat!, d.lon!);
|
||||
Destination? dss;
|
||||
if(ds.isNotEmpty){
|
||||
dss = ds.first;
|
||||
}
|
||||
|
||||
double checkinRadious = d.checkin_radious ?? double.infinity;
|
||||
bool autoCheckin = d.auto_checkin == 0 ? false : true;
|
||||
bool buyPoint = dss != null && dss.buy_point != null && dss.buy_point! > 0 ? true : false;
|
||||
bool buyPointImageAdded = dss != null && dss.buypoint_image != null ? true : false;
|
||||
bool locationAlreadyCheckedIn =
|
||||
ds.length > 0 && ds[0].checkedin == true ? true : false;
|
||||
bool isuserLoggedIn = indexController.currentUser.isNotEmpty ? true : false;
|
||||
@ -160,7 +166,7 @@ class DestinationController extends GetxController {
|
||||
|
||||
if (is_photo_shoot.value == true) {
|
||||
photos.clear();
|
||||
showModalBottomSheet(
|
||||
await showModalBottomSheet(
|
||||
constraints: BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
||||
context: Get.context!,
|
||||
isScrollControlled: true,
|
||||
@ -181,7 +187,7 @@ class DestinationController extends GetxController {
|
||||
chekcs = 1;
|
||||
is_in_checkin.value = true;
|
||||
is_at_start.value = true;
|
||||
showModalBottomSheet(
|
||||
await showModalBottomSheet(
|
||||
constraints:
|
||||
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
||||
context: Get.context!,
|
||||
@ -192,11 +198,12 @@ class DestinationController extends GetxController {
|
||||
is_at_start.value = false;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
return;
|
||||
} else if (is_in_rog.value == true && indexController.rog_mode == 1) {
|
||||
print("----- in location popup checkin cp - ${d.cp}----");
|
||||
chekcs = 2;
|
||||
is_in_checkin.value = true;
|
||||
showModalBottomSheet(
|
||||
await showModalBottomSheet(
|
||||
constraints:
|
||||
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
||||
context: Get.context!,
|
||||
@ -206,6 +213,7 @@ class DestinationController extends GetxController {
|
||||
chekcs = 0;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,6 +232,7 @@ class DestinationController extends GetxController {
|
||||
}
|
||||
skip_gps = false;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
print("--- hidden loc ${d.hidden_location} ----");
|
||||
// ask for checkin
|
||||
@ -234,7 +243,8 @@ class DestinationController extends GetxController {
|
||||
chekcs = 3;
|
||||
is_in_checkin.value = true;
|
||||
photos.clear();
|
||||
showModalBottomSheet(
|
||||
print("--- calling checkin ---");
|
||||
await showModalBottomSheet(
|
||||
constraints:
|
||||
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
||||
context: Get.context!,
|
||||
@ -247,10 +257,11 @@ class DestinationController extends GetxController {
|
||||
chekcs = 0;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
return;
|
||||
} else if (is_in_rog.value == true && d.cp != -1) {
|
||||
chekcs = 4;
|
||||
is_in_checkin.value = true;
|
||||
showMaterialModalBottomSheet(
|
||||
await showMaterialModalBottomSheet(
|
||||
expand: true,
|
||||
context: Get.context!,
|
||||
backgroundColor: Colors.transparent,
|
||||
@ -259,6 +270,7 @@ class DestinationController extends GetxController {
|
||||
chekcs = 0;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
return;
|
||||
// showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
// builder:((context) => BottomSheetNew())
|
||||
// ).whenComplete((){
|
||||
@ -268,6 +280,31 @@ class DestinationController extends GetxController {
|
||||
// });
|
||||
}
|
||||
}
|
||||
} else if (checkinRadious >= distance &&
|
||||
locationAlreadyCheckedIn == true &&
|
||||
buyPointImageAdded == false &&
|
||||
ds.isNotEmpty &&
|
||||
buyPoint == true &&
|
||||
is_in_rog.value == true) {
|
||||
chekcs = 5;
|
||||
is_in_checkin.value = true;
|
||||
photos.clear();
|
||||
print(
|
||||
"--- open buy point ${buyPointImageAdded} ${d.buypoint_image} ----");
|
||||
await showModalBottomSheet(
|
||||
constraints: BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
||||
context: Get.context!,
|
||||
isScrollControlled: true,
|
||||
builder: ((context) => CameraPage(
|
||||
destination: d,
|
||||
dbDest: ds.first,
|
||||
))).whenComplete(() {
|
||||
skip_gps = false;
|
||||
rogaining_counted.value = true;
|
||||
chekcs = 0;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
print("---- cp --- ${d.cp} -----");
|
||||
print("--- at goal $is_at_goal ---");
|
||||
@ -286,7 +323,7 @@ class DestinationController extends GetxController {
|
||||
chekcs = 5;
|
||||
is_at_goal.value = true;
|
||||
photos.clear();
|
||||
showModalBottomSheet(
|
||||
await showModalBottomSheet(
|
||||
constraints:
|
||||
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
||||
context: Get.context!,
|
||||
@ -298,6 +335,7 @@ class DestinationController extends GetxController {
|
||||
chekcs = 0;
|
||||
is_at_goal.value = false;
|
||||
});
|
||||
return;
|
||||
} else if (is_in_rog.value == false &&
|
||||
indexController.rog_mode == 1 &&
|
||||
DateTime.now().difference(last_goal_at).inHours >= 24) {
|
||||
@ -305,7 +343,7 @@ class DestinationController extends GetxController {
|
||||
print("---- in start -----");
|
||||
chekcs = 6;
|
||||
is_at_start.value = true;
|
||||
showModalBottomSheet(
|
||||
await showModalBottomSheet(
|
||||
constraints:
|
||||
BoxConstraints.loose(Size(Get.width, Get.height * 0.75)),
|
||||
context: Get.context!,
|
||||
@ -316,6 +354,7 @@ class DestinationController extends GetxController {
|
||||
chekcs = 0;
|
||||
is_at_start.value = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
print("==== _chekcs $chekcs ====");
|
||||
@ -358,7 +397,7 @@ class DestinationController extends GetxController {
|
||||
db.deleteAllDestinations().then((value) {
|
||||
PopulateDestinations();
|
||||
startGPSTimer();
|
||||
startGame();
|
||||
//startGame();
|
||||
//initGPS();
|
||||
});
|
||||
}
|
||||
@ -440,12 +479,12 @@ class DestinationController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void checkForCheckin() async {
|
||||
Future<void> checkForCheckin() async {
|
||||
print("--- Start of checkForCheckin function ---");
|
||||
|
||||
try {
|
||||
print("--- 000 ---- $skip_gps----");
|
||||
await Future.delayed(const Duration(milliseconds: 3500));
|
||||
await Future.delayed(const Duration(milliseconds: 2500));
|
||||
final la = current_lat;
|
||||
final ln = current_lon;
|
||||
for (GeoJsonFeature fs in indexController.locations[0].collection) {
|
||||
@ -458,20 +497,23 @@ class DestinationController extends GetxController {
|
||||
var distanceFs = const Distance();
|
||||
double distFs = distanceFs.as(
|
||||
LengthUnit.Meter, LatLng(latFs, lonFs), LatLng(la, ln));
|
||||
Destination des = festuretoDestination(fs);
|
||||
|
||||
if (distFs <= 250 && skip_gps == false) {
|
||||
if (distFs <= des.checkin_radious! && skip_gps == false) {
|
||||
print("--- 789 ---- $skip_gps----");
|
||||
//near a location
|
||||
print("---- before call startTimerLocation ----");
|
||||
startTimerLocation(fs, distFs);
|
||||
await startTimerLocation(fs, distFs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
print("--- 123 ---- $skip_gps----");
|
||||
} catch (e) {
|
||||
print("An error occurred: $e");
|
||||
await checkForCheckin();
|
||||
} finally {
|
||||
print("--- End of checkForCheckin function, calling recursively ---");
|
||||
checkForCheckin();
|
||||
await checkForCheckin();
|
||||
}
|
||||
}
|
||||
|
||||
@ -534,7 +576,15 @@ class DestinationController extends GetxController {
|
||||
saveGameState();
|
||||
}
|
||||
|
||||
void makeCheckin(
|
||||
Future<void> makeBuyPoint(Destination destination, String imageurl) async {
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
|
||||
await db.updateBuyPoint(destination, imageurl);
|
||||
PopulateDestinations();
|
||||
await GallerySaver.saveImage(imageurl);
|
||||
}
|
||||
|
||||
Future<void> makeCheckin(
|
||||
Destination destination, bool action, String imageurl) async {
|
||||
print(
|
||||
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${destination.sub_loc_id}@@@@@@@@@@@");
|
||||
@ -550,7 +600,7 @@ class DestinationController extends GetxController {
|
||||
|
||||
await GallerySaver.saveImage(imageurl);
|
||||
|
||||
//PopulateDestinations();
|
||||
PopulateDestinations();
|
||||
|
||||
/// post to NATNAT
|
||||
if (indexController.currentUser.isNotEmpty) {
|
||||
@ -656,7 +706,7 @@ class DestinationController extends GetxController {
|
||||
_GPStimer?.cancel();
|
||||
|
||||
// Start a new timer that fires every 3 seconds
|
||||
_timer = Timer.periodic(Duration(seconds: 3), (timer) async {
|
||||
_timer = Timer.periodic(Duration(seconds: 1), (timer) async {
|
||||
Position position = await Geolocator.getCurrentPosition(
|
||||
desiredAccuracy: LocationAccuracy.high);
|
||||
current_lat = position.latitude;
|
||||
@ -677,8 +727,8 @@ class DestinationController extends GetxController {
|
||||
_GPStimer?.cancel();
|
||||
}
|
||||
|
||||
void startGame() {
|
||||
checkForCheckin();
|
||||
Future<void> startGame() async {
|
||||
await checkForCheckin();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user