update
This commit is contained in:
@ -33,6 +33,10 @@ class DestinationController extends GetxController {
|
||||
List<bool> isSelected = [true].obs;
|
||||
BuildContext? context;
|
||||
|
||||
List<String> gps = <String>["-- stating --"].obs;
|
||||
List<String> locationPermission = <String>[" -- starting -- "].obs;
|
||||
|
||||
|
||||
Map<String, dynamic> matrix = {};
|
||||
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
@ -63,58 +67,63 @@ class DestinationController extends GetxController {
|
||||
checkForCheckin(double la, double ln){
|
||||
|
||||
for(final d in destinations){
|
||||
double lat = d.lat!;
|
||||
double lon = d.lon!;
|
||||
LatLng p = LatLng(lat, lon);
|
||||
getDEstinationForLatLong(lat, lon).then((value){
|
||||
var distance = Distance();
|
||||
double dist = distance.as(LengthUnit.Meter, LatLng(lat, lon), LatLng(la, ln));
|
||||
double rad = value!.checkin_radious ?? double.infinity;
|
||||
bool auto_checkin = value.auto_checkin == 0 ? false : true;
|
||||
|
||||
indexController.currentDestinationFeature.add(value);
|
||||
//indexController.getAction();
|
||||
if(!checking_in)
|
||||
{
|
||||
checking_in = true;
|
||||
double lat = d.lat!;
|
||||
double lon = d.lon!;
|
||||
LatLng p = LatLng(lat, lon);
|
||||
getDEstinationForLatLong(lat, lon).then((value){
|
||||
var distance = Distance();
|
||||
double dist = distance.as(LengthUnit.Meter, LatLng(lat, lon), LatLng(la, ln));
|
||||
double rad = value!.checkin_radious ?? double.infinity;
|
||||
bool auto_checkin = value.auto_checkin == 0 ? false : true;
|
||||
|
||||
indexController.currentDestinationFeature.add(value);
|
||||
//indexController.getAction();
|
||||
|
||||
|
||||
if(rad >= dist){
|
||||
if(auto_checkin){
|
||||
makeCheckin(value, true);
|
||||
if(rad >= dist){
|
||||
if(auto_checkin){
|
||||
makeCheckin(value, true);
|
||||
}
|
||||
else{
|
||||
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
builder:((context) => BottomSheetWidget())
|
||||
).whenComplete((){
|
||||
checking_in = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
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}");
|
||||
});
|
||||
// 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;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -137,7 +146,7 @@ class DestinationController extends GetxController {
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
checkPermission();
|
||||
checkPermission();
|
||||
PopulateDestinations();
|
||||
|
||||
|
||||
@ -147,7 +156,7 @@ class DestinationController extends GetxController {
|
||||
|
||||
if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
locationSettings = AndroidSettings(
|
||||
accuracy: LocationAccuracy.high,
|
||||
accuracy: LocationAccuracy.bestForNavigation,
|
||||
distanceFilter: 00,
|
||||
forceLocationManager: true,
|
||||
intervalDuration: const Duration(seconds: 1),
|
||||
@ -162,7 +171,7 @@ class DestinationController extends GetxController {
|
||||
);
|
||||
} else if (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS) {
|
||||
locationSettings = AppleSettings(
|
||||
accuracy: LocationAccuracy.high,
|
||||
accuracy: LocationAccuracy.bestForNavigation,
|
||||
activityType: ActivityType.fitness,
|
||||
distanceFilter: 1,
|
||||
pauseLocationUpdatesAutomatically: false,
|
||||
@ -176,22 +185,30 @@ class DestinationController extends GetxController {
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
|
||||
StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
|
||||
|
||||
(Position? position) {
|
||||
if(isSelected[0]){
|
||||
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}");
|
||||
gps.clear();
|
||||
gps.add("-- lat : ${position.latitude}, lon : ${position.longitude} --");
|
||||
checkForCheckin(position!.latitude, position.longitude);
|
||||
//});
|
||||
|
||||
}
|
||||
print(position == null ? 'Unknown' : 'current position is ${position.latitude.toString()}, ${position.longitude.toString()}');
|
||||
});
|
||||
} catch (err){
|
||||
locationPermission.clear();
|
||||
locationPermission.add(err.toString());
|
||||
}
|
||||
|
||||
(Position? position) {
|
||||
if(isSelected[0]){
|
||||
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()}');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -199,6 +216,8 @@ class DestinationController extends GetxController {
|
||||
LocationPermission permission = await Geolocator.checkPermission();
|
||||
if (permission != LocationPermission.whileInUse ||
|
||||
permission != LocationPermission.always) {
|
||||
locationPermission.clear();
|
||||
locationPermission.add(permission.name);
|
||||
permission = await Geolocator.requestPermission();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user