update
This commit is contained in:
@ -2,7 +2,6 @@
|
||||
package="com.example.rogapp">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
<application
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:rogapp/pages/index/index_binding.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/utils/string_values.dart';
|
||||
|
||||
void main() {
|
||||
//WidgetsFlutterBinding.ensureInitialized();
|
||||
runApp(const MyApp());
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -33,10 +33,57 @@ class MyApp extends StatelessWidget {
|
||||
popGesture: Get.isPopGestureEnable,
|
||||
transitionDuration: const Duration(milliseconds: 230),
|
||||
initialBinding: IndexBinding(), //HomeBinding(),
|
||||
initialRoute: AppPages.TRAVEL,
|
||||
initialRoute: AppPages.PERMISSION,
|
||||
getPages: AppPages.routes,
|
||||
enableLog: true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// class MyApp extends StatelessWidget {
|
||||
// MyApp({Key? key}) : super(key: key);
|
||||
|
||||
// // This widget is the root of your application.
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return MaterialApp(
|
||||
// title: 'Flutter Demo',
|
||||
// theme: ThemeData(
|
||||
// primaryColor: Color(0xfff00B074),
|
||||
// textTheme: const TextTheme(
|
||||
// bodyText1: TextStyle(
|
||||
// fontSize: 18.0,
|
||||
// fontFamily: 'Barlow-Medium',
|
||||
// color: Color(0xff464255)),
|
||||
// ),
|
||||
// ),
|
||||
// home: PermissionHandlerScreen(),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// class SplashScreen extends StatelessWidget {
|
||||
// const SplashScreen({Key? key}) : super(key: key);
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return WillPopScope(
|
||||
// onWillPop: () async {
|
||||
// SystemNavigator.pop();
|
||||
// return true;
|
||||
// },
|
||||
// child: Scaffold(
|
||||
// body: Center(
|
||||
// child: Text(
|
||||
// "Splash Screen",
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,7 +140,20 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
//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])
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
)
|
||||
));
|
||||
|
||||
79
lib/pages/permission/permission.dart
Normal file
79
lib/pages/permission/permission.dart
Normal file
@ -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<PermissionHandlerScreen> createState() => _PermissionHandlerScreenState();
|
||||
}
|
||||
|
||||
class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
|
||||
|
||||
@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<Map<Permission, PermissionStatus>> permissionServices() async {
|
||||
// You can request multiple permissions at once.
|
||||
Map<Permission, PermissionStatus> statuses = await [
|
||||
Permission.location,
|
||||
|
||||
//add more permission to request here.
|
||||
].request();
|
||||
|
||||
if (statuses[Permission.location]!.isPermanentlyDenied) {
|
||||
await openAppSettings().then(
|
||||
(value) async {
|
||||
if (value) {
|
||||
if (await Permission.location.status.isPermanentlyDenied == true &&
|
||||
await Permission.location.status.isGranted == false) {
|
||||
// openAppSettings();
|
||||
permissionServiceCall(); /* opens app settings until permission is granted */
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
} else {
|
||||
if (statuses[Permission.location]!.isDenied) {
|
||||
permissionServiceCall();
|
||||
}
|
||||
}
|
||||
|
||||
/*{Permission.camera: PermissionStatus.granted, Permission.storage: PermissionStatus.granted}*/
|
||||
return statuses;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@ import 'package:rogapp/pages/index/index_page.dart';
|
||||
import 'package:rogapp/pages/landing/landing_page.dart';
|
||||
import 'package:rogapp/pages/loading/loading_page.dart';
|
||||
import 'package:rogapp/pages/login/login_page.dart';
|
||||
import 'package:rogapp/pages/permission/permission.dart';
|
||||
import 'package:rogapp/pages/register/register_page.dart';
|
||||
import 'package:rogapp/spa/spa_binding.dart';
|
||||
import 'package:rogapp/spa/spa_page.dart';
|
||||
@ -30,6 +31,7 @@ class AppPages {
|
||||
static const LOADING = Routes.LOADING;
|
||||
static const DESTINATION_MAP = Routes.DESTINATION_MAP;
|
||||
static const HOME = Routes.HOME;
|
||||
static const PERMISSION = Routes.PERMISSION;
|
||||
|
||||
static final routes = [
|
||||
// GetPage(
|
||||
@ -87,5 +89,9 @@ class AppPages {
|
||||
page: () => HomePage(),
|
||||
binding: HomeBinding(),
|
||||
),
|
||||
GetPage(
|
||||
name: Routes.PERMISSION,
|
||||
page: () => PermissionHandlerScreen(),
|
||||
)
|
||||
];
|
||||
}
|
||||
@ -15,4 +15,5 @@ abstract class Routes {
|
||||
static const LOADING = '/loading';
|
||||
static const DESTINATION_MAP = '/destination_map';
|
||||
static const HOME = '/home';
|
||||
static const PERMISSION = '/permission';
|
||||
}
|
||||
|
||||
@ -239,31 +239,31 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
],
|
||||
),
|
||||
Obx(() =>
|
||||
(indexController.currentFeature[0].properties!["address"] as String).isNotEmpty ?
|
||||
indexController.currentFeature[0].properties!["address"] != null && (indexController.currentFeature[0].properties!["address"] as String).isNotEmpty ?
|
||||
getDetails(context, "address".tr, indexController.currentFeature[0].properties!["address"] ?? '')
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
),
|
||||
Obx(() =>
|
||||
(indexController.currentFeature[0].properties!["phone"] as String).isNotEmpty ?
|
||||
indexController.currentFeature[0].properties!["phone"] != null && (indexController.currentFeature[0].properties!["phone"] as String).isNotEmpty ?
|
||||
getDetails(context, "telephone".tr, indexController.currentFeature[0].properties!["phone"] ?? '')
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
),
|
||||
Obx(() =>
|
||||
(indexController.currentFeature[0].properties!["email"] as String).isNotEmpty ?
|
||||
indexController.currentFeature[0].properties!["email"] != null && (indexController.currentFeature[0].properties!["email"] as String).isNotEmpty ?
|
||||
getDetails(context, "email".tr, indexController.currentFeature[0].properties!["email"] ?? '')
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
),
|
||||
Obx(() =>
|
||||
(indexController.currentFeature[0].properties!["webcontents"] as String).isNotEmpty ?
|
||||
indexController.currentFeature[0].properties!["webcontents"] != null && (indexController.currentFeature[0].properties!["webcontents"] as String).isNotEmpty ?
|
||||
getDetails(context, "web".tr, indexController.currentFeature[0].properties!["webcontents"] ?? '', isurl: true)
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
),
|
||||
Obx(() =>
|
||||
(indexController.currentFeature[0].properties!["videos"] as String).isNotEmpty ?
|
||||
indexController.currentFeature[0].properties!["videos"] !=null && (indexController.currentFeature[0].properties!["videos"] as String).isNotEmpty ?
|
||||
getDetails(context, "video".tr, indexController.currentFeature[0].properties!["videos"] ?? '', isurl: true)
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
|
||||
@ -52,8 +52,8 @@ class ListWidget extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
leading: getImage(index),
|
||||
title: Text(indexController.locations[0].collection[index].properties!['location_name'].toString()),
|
||||
subtitle: Text(indexController.locations[0].collection[index].properties!['category']),
|
||||
title: indexController.locations[0].collection[index].properties!['location_name'] != null ? Text(indexController.locations[0].collection[index].properties!['location_name'].toString()) : Text(""),
|
||||
subtitle: indexController.locations[0].collection[index].properties!['category'] != null ? Text(indexController.locations[0].collection[index].properties!['category']) : Text(""),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
21
pubspec.lock
21
pubspec.lock
@ -138,28 +138,28 @@ packages:
|
||||
name: flutter_map
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.14.0"
|
||||
version: "1.1.1"
|
||||
flutter_map_location_marker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_map_location_marker
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
version: "4.1.0"
|
||||
flutter_map_marker_cluster:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_map_marker_cluster
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.4"
|
||||
version: "0.5.0"
|
||||
flutter_map_marker_popup:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_map_marker_popup
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
version: "2.2.1"
|
||||
flutter_plugin_android_lifecycle:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -211,7 +211,7 @@ packages:
|
||||
name: geolocator_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.1.8"
|
||||
version: "3.2.1"
|
||||
geolocator_apple:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -506,6 +506,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
polylabel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: polylabel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
positioned_tap_detector:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -743,5 +750,5 @@ packages:
|
||||
source: hosted
|
||||
version: "0.2.0+1"
|
||||
sdks:
|
||||
dart: ">=2.17.0-0 <3.0.0"
|
||||
flutter: ">=2.10.0"
|
||||
dart: ">=2.17.0 <3.0.0"
|
||||
flutter: ">=3.0.0"
|
||||
|
||||
@ -13,7 +13,7 @@ import 'package:rogapp/main.dart';
|
||||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(const MyApp());
|
||||
await tester.pumpWidget( MyApp());
|
||||
|
||||
// Verify that our counter starts at 0.
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
|
||||
Reference in New Issue
Block a user