update for chech in

This commit is contained in:
Mohamed Nouffer
2022-07-14 23:10:24 +05:30
parent 264cd828f4
commit 42accf9f3a
10 changed files with 532 additions and 311 deletions

View File

@ -61,6 +61,7 @@ class DestinationController extends GetxController {
}
checkForCheckin(double la, double ln){
for(final d in destinations){
double lat = d.lat!;
double lon = d.lon!;
@ -74,40 +75,71 @@ class DestinationController extends GetxController {
indexController.currentDestinationFeature.add(value);
//indexController.getAction();
if(!checking_in){
checking_in = true;
if(rad >= dist){
if(auto_checkin){
if(indexController.currentAction.isNotEmpty){
print(indexController.currentAction[0]);
indexController.currentAction[0][0]["checkin"] = true;
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
indexController.currentAction.clear();
print("---temp---${temp}");
indexController.currentAction.add([temp]);
}
indexController.makeAction(Get.context!);
}
else{
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
if(rad >= dist){
if(auto_checkin){
makeCheckin(value, true);
}
else{
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
builder:((context) => BottomSheetWidget())
).whenComplete((){
checking_in = false;
});
}
}
}
// if(!checking_in){
// checking_in = true;
// if(rad >= dist){
// if(auto_checkin){
// if(indexController.currentAction.isNotEmpty){
// print(indexController.currentAction[0]);
// indexController.currentAction[0][0]["checkin"] = true;
// Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
// indexController.currentAction.clear();
// print("---temp---${temp}");
// indexController.currentAction.add([temp]);
// }
// indexController.makeAction(Get.context!);
// }
// else{
// showModalBottomSheet(context: Get.context!, isScrollControlled: true,
// builder:((context) => BottomSheetWidget())
// ).whenComplete((){
// checking_in = false;
// });
// }
// }
// }
print("----- rad is ${rad}");
});
}
}
void makeCheckin(Destination destination, bool action) async {
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${action}@@@@@@@@@@@");
DatabaseHelper db = DatabaseHelper.instance;
int res = await db.updateAction(destination, action);
List<Destination> ddd = await db.getDestinationByLatLon(destination.lat!, destination.lon!);
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ddddd ${ddd[0].checkedin} @@@@@@@@@@@");
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${res}@@@@@@@@@@@");
PopulateDestinations();
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ after populating ${res} @@@@@@@@@@@");
print("---- database update resulr ------ res : ${res}-------");
}
@override
void onInit() {
void onInit() async {
super.onInit();
checkPermission();
PopulateDestinations();
print("------ in iniit");
@ -146,14 +178,16 @@ class DestinationController extends GetxController {
StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
(Position? position) {
double czoom = indexController.rogMapController!.zoom;
indexController.rogMapController!.move(LatLng(position!.latitude, position!.longitude), czoom);
if(isSelected[0]){
String user_id = indexController.currentUser[0]["user"]["id"].toString();
TrackingService.addTrack(user_id, position!.latitude, position.longitude).then((val){
//checkForCheckin(position!.latitude, position.longitude);
});
double czoom = indexController.rogMapController!.zoom;
indexController.rogMapController!.move(LatLng(position!.latitude, position!.longitude), czoom);
//String user_id = indexController.currentUser[0]["user"]["id"].toString();
//TrackingService.addTrack(user_id, position!.latitude, position.longitude).then((val){
print("---- postion is ${position.latitude}, ${position.longitude}");
checkForCheckin(position!.latitude, position.longitude);
//});
}
print(position == null ? 'Unknown' : 'current position is ${position.latitude.toString()}, ${position.longitude.toString()}');
@ -161,6 +195,14 @@ class DestinationController extends GetxController {
}
void checkPermission() async {
LocationPermission permission = await Geolocator.checkPermission();
if (permission != LocationPermission.whileInUse ||
permission != LocationPermission.always) {
permission = await Geolocator.requestPermission();
}
}
void deleteDestination(Destination d){
//int id = destinations[index].location_id!;
//print("---- index ${destinations[index].location_id!}-----");
@ -215,11 +257,9 @@ class DestinationController extends GetxController {
DatabaseHelper db = DatabaseHelper.instance;
db.getDestinations().then((value){
for(Destination d in value){
print("-- destination controller Populating destination -- ${d.name}-----::::");
for(Destination s in currentSelectedDestinations){
if(d.location_id == s.location_id){
d.selected = !d.selected;
d.selected = !d.selected!;
}
}