diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 928e324..8512568 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -2,7 +2,6 @@
package="com.example.rogapp">
-
isSelected = [true].obs;
BuildContext? context;
+ List gps = ["-- stating --"].obs;
+ List locationPermission = [" -- starting -- "].obs;
+
+
Map matrix = {};
final IndexController indexController = Get.find();
@@ -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 temp = Map.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 temp = Map.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 positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
+ StreamSubscription 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();
}
}
diff --git a/lib/pages/destination_map/destination_map_page.dart b/lib/pages/destination_map/destination_map_page.dart
index b7d0002..8a1864e 100644
--- a/lib/pages/destination_map/destination_map_page.dart
+++ b/lib/pages/destination_map/destination_map_page.dart
@@ -140,7 +140,20 @@ class _DestinationMapPageState extends State {
//child: TravelMap(),
child:
TravelMap(),
- )
+ ),
+ Positioned(
+ bottom: 200,
+ left: 10,
+ child: Container(
+ color: Colors.white,
+ child: Row(
+ children: [
+ Text(destinationController.gps[0]),
+ Text(destinationController.locationPermission[0])
+ ],
+ ),
+ )
+ ),
],
)
));
diff --git a/lib/pages/permission/permission.dart b/lib/pages/permission/permission.dart
new file mode 100644
index 0000000..c4b2890
--- /dev/null
+++ b/lib/pages/permission/permission.dart
@@ -0,0 +1,79 @@
+import 'package:flutter/material.dart';
+import 'package:get/get.dart';
+import 'package:permission_handler/permission_handler.dart';
+import 'package:rogapp/routes/app_pages.dart';
+
+class PermissionHandlerScreen extends StatefulWidget {
+ PermissionHandlerScreen({Key? key}) : super(key: key);
+
+ @override
+ State createState() => _PermissionHandlerScreenState();
+}
+
+class _PermissionHandlerScreenState extends State {
+
+ @override
+ void initState() {
+ // TODO: implement initState
+ super.initState();
+ permissionServiceCall();
+ }
+
+ permissionServiceCall() async {
+ await permissionServices().then(
+ (value) {
+ if (value != null) {
+ if (value[Permission.location]!.isGranted ) {
+ /* ========= New Screen Added ============= */
+
+ Get.toNamed(AppPages.TRAVEL);
+
+ // Navigator.pushReplacement(
+ // context,
+ // MaterialPageRoute(builder: (context) => SplashScreen()),
+ // );
+ }
+ }
+ },
+ );
+ }
+
+
+ /*Permission services*/
+ Future