optimized and removed travel mode
This commit is contained in:
@ -85,10 +85,6 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
||||
case AppLifecycleState.resumed:
|
||||
//print("RESUMED");
|
||||
restoreGame();
|
||||
if (destinationController.positionStream == null) {
|
||||
//destinationController.startGPSTimer();
|
||||
//destinationController.startGame();
|
||||
}
|
||||
break;
|
||||
case AppLifecycleState.inactive:
|
||||
//print("INACTIVE");
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:camera_camera/camera_camera.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
@ -30,6 +28,8 @@ import 'package:gallery_saver/gallery_saver.dart';
|
||||
class DestinationController extends GetxController {
|
||||
late LocationSettings locationSettings;
|
||||
|
||||
Timer? _GPStimer;
|
||||
|
||||
var destinationCount = 0.obs;
|
||||
List<Destination> destinations = <Destination>[].obs;
|
||||
double currentLat = 0.0;
|
||||
@ -54,10 +54,6 @@ class DestinationController extends GetxController {
|
||||
List<String> gps = <String>["-- stating --"].obs;
|
||||
List<String> locationPermission = <String>[" -- starting -- "].obs;
|
||||
|
||||
StreamSubscription<Position>? positionStream;
|
||||
|
||||
Timer? gpsTimer;
|
||||
|
||||
var travelMode = 0.obs;
|
||||
|
||||
bool skipGps = false;
|
||||
@ -68,7 +64,6 @@ class DestinationController extends GetxController {
|
||||
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
Timer? _timer;
|
||||
int _start = 0;
|
||||
int chekcs = 0;
|
||||
var rogainingCounted = false.obs;
|
||||
@ -125,7 +120,7 @@ class DestinationController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> startTimer(Destination d, double distance) async {
|
||||
//print("=== passed dest is ${d.location_id} ${d.checkedin} ====");
|
||||
print("=== passed dest is ${d.location_id} ${d.checkedin} ====");
|
||||
skipGps = true;
|
||||
//print("---- in startTimer ----");
|
||||
|
||||
@ -388,21 +383,12 @@ class DestinationController extends GetxController {
|
||||
lastGoalAt = DateTime.fromMicrosecondsSinceEpoch(latgoal);
|
||||
//print("===== last goal : $last_goal_at =====");
|
||||
}
|
||||
|
||||
//deleteDBDestinations();
|
||||
|
||||
// currentSelectedDestinations.forEach((element) {
|
||||
// deleteDestination(element);
|
||||
// });
|
||||
}
|
||||
|
||||
void deleteAllDestinations() {
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
db.deleteAllDestinations().then((value) {
|
||||
populateDestinations();
|
||||
//startGPSTimer();
|
||||
//startGame();
|
||||
//initGPS();
|
||||
});
|
||||
}
|
||||
|
||||
@ -510,13 +496,18 @@ class DestinationController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> checkForCheckin() async {
|
||||
//print("--- Start of checkForCheckin function ---");
|
||||
print("--- Start of checkForCheckin function ---");
|
||||
|
||||
try {
|
||||
//print("--- 000 ---- $skip_gps----");
|
||||
await Future.delayed(const Duration(milliseconds: 2500));
|
||||
final la = currentLat;
|
||||
final ln = currentLon;
|
||||
Position position = await Geolocator.getCurrentPosition(
|
||||
desiredAccuracy: LocationAccuracy.bestForNavigation);
|
||||
currentLat = position.latitude;
|
||||
currentLon = position.longitude;
|
||||
final la = position.latitude;
|
||||
final ln = position.longitude;
|
||||
|
||||
for (GeoJsonFeature fs in indexController.locations[0].collection) {
|
||||
GeoJsonMultiPoint mp = fs.geometry as GeoJsonMultiPoint;
|
||||
LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude,
|
||||
@ -525,10 +516,16 @@ class DestinationController extends GetxController {
|
||||
double latFs = pt.latitude;
|
||||
double lonFs = pt.longitude;
|
||||
var distanceFs = const Distance();
|
||||
//print("--- points : ${pt.latitude}, ${pt.longitude} ----");
|
||||
//print("--- points : ${pt.latitude}, ${pt.longitude} ----");
|
||||
double distFs = distanceFs.as(
|
||||
LengthUnit.Meter, LatLng(latFs, lonFs), LatLng(la, ln));
|
||||
Destination des = festuretoDestination(fs);
|
||||
|
||||
print(
|
||||
"--- position is ---- ${position.longitude}, --- ${position.longitude}----");
|
||||
|
||||
print("--- distFs ---- $distFs, --- ${des.checkin_radious}----");
|
||||
if (distFs <= des.checkin_radious! && skipGps == false) {
|
||||
//print("--- 789 ---- $skip_gps----");
|
||||
//near a location
|
||||
@ -642,21 +639,18 @@ class DestinationController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> startGame() async {
|
||||
//print("------ starting game ------");
|
||||
await checkForCheckin();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
positionStream?.cancel();
|
||||
gpsTimer?.cancel();
|
||||
super.onClose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
//initGPS();
|
||||
//startGPSTimer();
|
||||
startGame();
|
||||
super.onInit();
|
||||
}
|
||||
@ -697,7 +691,7 @@ class DestinationController extends GetxController {
|
||||
|
||||
void fixMapBound(String token) {
|
||||
//String _token = indexController.currentUser[0]["token"];
|
||||
indexController.switchPage(AppPages.INITIAL);
|
||||
indexController.switchPage(AppPages.INDEX);
|
||||
LocationService.getLocationsExt(token).then((value) {
|
||||
if (value != null) {
|
||||
//print("--- loc ext is - $value ----");
|
||||
|
||||
@ -1,252 +1,252 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/destination_map/destination_map_page.dart';
|
||||
import 'package:rogapp/pages/drawer/drawer_page.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/widgets/destination_widget.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:geolocator/geolocator.dart';
|
||||
// import 'package:get/get.dart';
|
||||
// import 'package:latlong2/latlong.dart';
|
||||
// import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
// import 'package:rogapp/pages/destination_map/destination_map_page.dart';
|
||||
// import 'package:rogapp/pages/drawer/drawer_page.dart';
|
||||
// import 'package:rogapp/pages/index/index_controller.dart';
|
||||
// import 'package:rogapp/routes/app_pages.dart';
|
||||
// import 'package:rogapp/widgets/destination_widget.dart';
|
||||
|
||||
class XDestnationPage extends StatelessWidget {
|
||||
XDestnationPage({Key? key}) : super(key: key);
|
||||
// class XDestnationPage extends StatelessWidget {
|
||||
// XDestnationPage({Key? key}) : super(key: key);
|
||||
|
||||
final DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
// final DestinationController destinationController =
|
||||
// Get.find<DestinationController>();
|
||||
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
// final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
final List<int> _items = List<int>.generate(50, (int index) => index);
|
||||
// final List<int> _items = List<int>.generate(50, (int index) => index);
|
||||
|
||||
Future<void> showCurrentPosition() async {
|
||||
LocationPermission permission = await Geolocator.checkPermission();
|
||||
if (permission != LocationPermission.whileInUse ||
|
||||
permission != LocationPermission.always) {
|
||||
permission = await Geolocator.requestPermission();
|
||||
}
|
||||
Position position = await Geolocator.getCurrentPosition(
|
||||
desiredAccuracy: LocationAccuracy.high,
|
||||
forceAndroidLocationManager: true);
|
||||
indexController.rogMapController
|
||||
.move(LatLng(position.latitude, position.longitude), 14);
|
||||
}
|
||||
// Future<void> showCurrentPosition() async {
|
||||
// LocationPermission permission = await Geolocator.checkPermission();
|
||||
// if (permission != LocationPermission.whileInUse ||
|
||||
// permission != LocationPermission.always) {
|
||||
// permission = await Geolocator.requestPermission();
|
||||
// }
|
||||
// Position position = await Geolocator.getCurrentPosition(
|
||||
// desiredAccuracy: LocationAccuracy.high,
|
||||
// forceAndroidLocationManager: true);
|
||||
// indexController.rogMapController
|
||||
// .move(LatLng(position.latitude, position.longitude), 14);
|
||||
// }
|
||||
|
||||
Image getImage(int index) {
|
||||
if (destinationController.destinations[index].photos == null ||
|
||||
destinationController.destinations[index].photos == "") {
|
||||
return const Image(image: AssetImage('assets/images/empty_image.png'));
|
||||
} else {
|
||||
return Image(
|
||||
image:
|
||||
NetworkImage(destinationController.destinations[index].photos!));
|
||||
}
|
||||
}
|
||||
// Image getImage(int index) {
|
||||
// if (destinationController.destinations[index].photos == null ||
|
||||
// destinationController.destinations[index].photos == "") {
|
||||
// return const Image(image: AssetImage('assets/images/empty_image.png'));
|
||||
// } else {
|
||||
// return Image(
|
||||
// image:
|
||||
// NetworkImage(destinationController.destinations[index].photos!));
|
||||
// }
|
||||
// }
|
||||
|
||||
Widget getRoutingImage(int route) {
|
||||
switch (route) {
|
||||
case 0:
|
||||
return const Image(
|
||||
image: AssetImage('assets/images/p4_9_man.png'),
|
||||
width: 35.0,
|
||||
);
|
||||
case 1:
|
||||
return const Image(
|
||||
image: AssetImage('assets/images/p4_8_car.png'),
|
||||
width: 35.0,
|
||||
);
|
||||
case 2:
|
||||
return const Image(
|
||||
image: AssetImage('assets/images/p4_10_train.png'),
|
||||
width: 35.0,
|
||||
);
|
||||
default:
|
||||
return const Image(
|
||||
image: AssetImage('assets/images/p4_9_man.png'),
|
||||
width: 35.0,
|
||||
);
|
||||
}
|
||||
}
|
||||
// Widget getRoutingImage(int route) {
|
||||
// switch (route) {
|
||||
// case 0:
|
||||
// return const Image(
|
||||
// image: AssetImage('assets/images/p4_9_man.png'),
|
||||
// width: 35.0,
|
||||
// );
|
||||
// case 1:
|
||||
// return const Image(
|
||||
// image: AssetImage('assets/images/p4_8_car.png'),
|
||||
// width: 35.0,
|
||||
// );
|
||||
// case 2:
|
||||
// return const Image(
|
||||
// image: AssetImage('assets/images/p4_10_train.png'),
|
||||
// width: 35.0,
|
||||
// );
|
||||
// default:
|
||||
// return const Image(
|
||||
// image: AssetImage('assets/images/p4_9_man.png'),
|
||||
// width: 35.0,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
indexController.switchPage(AppPages.INITIAL);
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
drawer: DrawerPage(),
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 13.0),
|
||||
child: InkWell(
|
||||
child: Obx((() => getRoutingImage(
|
||||
destinationController.travelMode.value))),
|
||||
onTap: () {
|
||||
Get.bottomSheet(
|
||||
Obx(
|
||||
() => ListView(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 30.0, bottom: 30),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"select_travel_mode".tr,
|
||||
style: const TextStyle(
|
||||
fontSize: 22.0,
|
||||
color: Colors.red,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
selected:
|
||||
destinationController.travelMode.value ==
|
||||
0
|
||||
? true
|
||||
: false,
|
||||
selectedTileColor: Colors.amber.shade200,
|
||||
leading: const Image(
|
||||
image: AssetImage(
|
||||
'assets/images/p4_9_man.png'),
|
||||
),
|
||||
title: Text("walking".tr),
|
||||
onTap: () {
|
||||
destinationController.travelMode.value = 0;
|
||||
destinationController
|
||||
.populateDestinations();
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
selected:
|
||||
destinationController.travelMode.value ==
|
||||
1
|
||||
? true
|
||||
: false,
|
||||
selectedTileColor: Colors.amber.shade200,
|
||||
leading: const Image(
|
||||
image: AssetImage(
|
||||
'assets/images/p4_8_car.png'),
|
||||
),
|
||||
title: Text("driving".tr),
|
||||
onTap: () {
|
||||
destinationController.travelMode.value = 1;
|
||||
destinationController
|
||||
.populateDestinations();
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
// ListTile(
|
||||
// selected: destinationController.travelMode == 2 ? true : false,
|
||||
// selectedTileColor: Colors.amber.shade200,
|
||||
// leading: Image(image: AssetImage('assets/images/p4_10_train.png'),),
|
||||
// title: Text("transit".tr),
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return WillPopScope(
|
||||
// onWillPop: () async {
|
||||
// indexController.switchPage(AppPages.INITIAL);
|
||||
// return false;
|
||||
// },
|
||||
// child: Scaffold(
|
||||
// drawer: DrawerPage(),
|
||||
// bottomNavigationBar: BottomAppBar(
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: <Widget>[
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(left: 13.0),
|
||||
// child: InkWell(
|
||||
// child: Obx((() => getRoutingImage(
|
||||
// destinationController.travelMode.value))),
|
||||
// onTap: () {
|
||||
// destinationController.travelMode.value = 2;
|
||||
// destinationController.PopulateDestinations();
|
||||
// Get.bottomSheet(
|
||||
// Obx(
|
||||
// () => ListView(
|
||||
// children: [
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(
|
||||
// top: 30.0, bottom: 30),
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// "select_travel_mode".tr,
|
||||
// style: const TextStyle(
|
||||
// fontSize: 22.0,
|
||||
// color: Colors.red,
|
||||
// fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ListTile(
|
||||
// selected:
|
||||
// destinationController.travelMode.value ==
|
||||
// 0
|
||||
// ? true
|
||||
// : false,
|
||||
// selectedTileColor: Colors.amber.shade200,
|
||||
// leading: const Image(
|
||||
// image: AssetImage(
|
||||
// 'assets/images/p4_9_man.png'),
|
||||
// ),
|
||||
// title: Text("walking".tr),
|
||||
// onTap: () {
|
||||
// destinationController.travelMode.value = 0;
|
||||
// destinationController
|
||||
// .populateDestinations();
|
||||
// Get.back();
|
||||
// },
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
isScrollControlled: false,
|
||||
backgroundColor: Colors.white,
|
||||
);
|
||||
//destinationController.PopulateDestinations();
|
||||
}),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.travel_explore,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () {
|
||||
indexController.switchPage(AppPages.INITIAL);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
//print("######");
|
||||
indexController.toggleDestinationMode();
|
||||
},
|
||||
tooltip: 'Increment',
|
||||
elevation: 4.0,
|
||||
child: Obx(() => indexController.desinationMode.value == 1
|
||||
? const Image(image: AssetImage('assets/images/list2.png'))
|
||||
: const Image(image: AssetImage('assets/images/map.png'))),
|
||||
),
|
||||
floatingActionButtonLocation:
|
||||
FloatingActionButtonLocation.centerDocked,
|
||||
appBar: AppBar(
|
||||
automaticallyImplyLeading: true,
|
||||
title: Text("app_title".tr),
|
||||
actions: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Get.toNamed(AppPages.CAMERA_PAGE);
|
||||
},
|
||||
child: destinationController.isInRog.value == true
|
||||
? Image.asset(
|
||||
"assets/images/basic-walking.gif",
|
||||
height: 10.0,
|
||||
)
|
||||
: destinationController.isAtGoal.value == true
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
Get.toNamed(AppPages.CAMERA_PAGE);
|
||||
},
|
||||
icon: const Icon(Icons.assistant_photo),
|
||||
)
|
||||
: IconButton(
|
||||
onPressed: () {
|
||||
Get.toNamed(AppPages.CAMERA_PAGE);
|
||||
},
|
||||
icon: const Icon(Icons.accessibility),
|
||||
),
|
||||
),
|
||||
// Obx(() =>
|
||||
// Text(indexController.connectionStatusName.value)
|
||||
// ListTile(
|
||||
// selected:
|
||||
// destinationController.travelMode.value ==
|
||||
// 1
|
||||
// ? true
|
||||
// : false,
|
||||
// selectedTileColor: Colors.amber.shade200,
|
||||
// leading: const Image(
|
||||
// image: AssetImage(
|
||||
// 'assets/images/p4_8_car.png'),
|
||||
// ),
|
||||
Obx(
|
||||
() => ToggleButtons(
|
||||
disabledColor: Colors.grey.shade200,
|
||||
selectedColor: Colors.red,
|
||||
onPressed: (int index) {
|
||||
destinationController.isGpsSelected.value =
|
||||
!destinationController.isGpsSelected.value;
|
||||
if (destinationController.isGpsSelected.value) {
|
||||
destinationController.chekcs = 0;
|
||||
destinationController.skipGps = false;
|
||||
//destinationController.resetRogaining();
|
||||
}
|
||||
},
|
||||
isSelected: [destinationController.isGpsSelected.value],
|
||||
children: const <Widget>[
|
||||
Icon(
|
||||
Icons.explore,
|
||||
size: 35.0,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
// IconButton(onPressed: (){
|
||||
// showCurrentPosition();
|
||||
// title: Text("driving".tr),
|
||||
// onTap: () {
|
||||
// destinationController.travelMode.value = 1;
|
||||
// destinationController
|
||||
// .populateDestinations();
|
||||
// Get.back();
|
||||
// },
|
||||
// icon: Icon(Icons.location_on_outlined))
|
||||
],
|
||||
),
|
||||
body: Obx(() => indexController.desinationMode.value == 0
|
||||
? DestinationWidget()
|
||||
: DestinationMapPage())),
|
||||
);
|
||||
}
|
||||
}
|
||||
// ),
|
||||
// // ListTile(
|
||||
// // selected: destinationController.travelMode == 2 ? true : false,
|
||||
// // selectedTileColor: Colors.amber.shade200,
|
||||
// // leading: Image(image: AssetImage('assets/images/p4_10_train.png'),),
|
||||
// // title: Text("transit".tr),
|
||||
// // onTap:(){
|
||||
// // destinationController.travelMode.value = 2;
|
||||
// // destinationController.PopulateDestinations();
|
||||
// // Get.back();
|
||||
// // },
|
||||
// // ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// isScrollControlled: false,
|
||||
// backgroundColor: Colors.white,
|
||||
// );
|
||||
// //destinationController.PopulateDestinations();
|
||||
// }),
|
||||
// ),
|
||||
// IconButton(
|
||||
// icon: const Icon(
|
||||
// Icons.travel_explore,
|
||||
// size: 35,
|
||||
// ),
|
||||
// onPressed: () {
|
||||
// indexController.switchPage(AppPages.INITIAL);
|
||||
// }),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// floatingActionButton: FloatingActionButton(
|
||||
// onPressed: () {
|
||||
// //print("######");
|
||||
// indexController.toggleDestinationMode();
|
||||
// },
|
||||
// tooltip: 'Increment',
|
||||
// elevation: 4.0,
|
||||
// child: Obx(() => indexController.desinationMode.value == 1
|
||||
// ? const Image(image: AssetImage('assets/images/list2.png'))
|
||||
// : const Image(image: AssetImage('assets/images/map.png'))),
|
||||
// ),
|
||||
// floatingActionButtonLocation:
|
||||
// FloatingActionButtonLocation.centerDocked,
|
||||
// appBar: AppBar(
|
||||
// automaticallyImplyLeading: true,
|
||||
// title: Text("app_title".tr),
|
||||
// actions: [
|
||||
// InkWell(
|
||||
// onTap: () {
|
||||
// Get.toNamed(AppPages.CAMERA_PAGE);
|
||||
// },
|
||||
// child: destinationController.isInRog.value == true
|
||||
// ? Image.asset(
|
||||
// "assets/images/basic-walking.gif",
|
||||
// height: 10.0,
|
||||
// )
|
||||
// : destinationController.isAtGoal.value == true
|
||||
// ? IconButton(
|
||||
// onPressed: () {
|
||||
// Get.toNamed(AppPages.CAMERA_PAGE);
|
||||
// },
|
||||
// icon: const Icon(Icons.assistant_photo),
|
||||
// )
|
||||
// : IconButton(
|
||||
// onPressed: () {
|
||||
// Get.toNamed(AppPages.CAMERA_PAGE);
|
||||
// },
|
||||
// icon: const Icon(Icons.accessibility),
|
||||
// ),
|
||||
// ),
|
||||
// // Obx(() =>
|
||||
// // Text(indexController.connectionStatusName.value)
|
||||
// // ),
|
||||
// Obx(
|
||||
// () => ToggleButtons(
|
||||
// disabledColor: Colors.grey.shade200,
|
||||
// selectedColor: Colors.red,
|
||||
// onPressed: (int index) {
|
||||
// destinationController.isGpsSelected.value =
|
||||
// !destinationController.isGpsSelected.value;
|
||||
// if (destinationController.isGpsSelected.value) {
|
||||
// destinationController.chekcs = 0;
|
||||
// destinationController.skipGps = false;
|
||||
// //destinationController.resetRogaining();
|
||||
// }
|
||||
// },
|
||||
// isSelected: [destinationController.isGpsSelected.value],
|
||||
// children: const <Widget>[
|
||||
// Icon(
|
||||
// Icons.explore,
|
||||
// size: 35.0,
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// // IconButton(onPressed: (){
|
||||
// // showCurrentPosition();
|
||||
// // },
|
||||
// // icon: Icon(Icons.location_on_outlined))
|
||||
// ],
|
||||
// ),
|
||||
// body: Obx(() => indexController.desinationMode.value == 0
|
||||
// ? DestinationWidget()
|
||||
// : DestinationMapPage())),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -10,15 +10,10 @@ import 'package:geojson/geojson.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/pages/destination/destination_binding.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/destination/destination_page.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/services/action_service.dart';
|
||||
import 'package:rogapp/services/auth_service.dart';
|
||||
import 'package:rogapp/services/cat_service.dart';
|
||||
import 'package:rogapp/services/location_service.dart';
|
||||
import 'package:rogapp/services/perfecture_service.dart';
|
||||
import 'package:rogapp/utils/database_helper.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
@ -68,8 +63,6 @@ class IndexController extends GetxController {
|
||||
String areaDropdownValue = "-1";
|
||||
String cateogory = "-all-";
|
||||
|
||||
late Worker _ever;
|
||||
|
||||
ConnectivityResult connectionStatus = ConnectivityResult.none;
|
||||
var connectionStatusName = "".obs;
|
||||
final Connectivity _connectivity = Connectivity();
|
||||
@ -94,7 +87,7 @@ class IndexController extends GetxController {
|
||||
void switchPage(String page) {
|
||||
////print("######## ${currentUser[0]["user"]["id"]}");
|
||||
switch (page) {
|
||||
case AppPages.INITIAL:
|
||||
case AppPages.INDEX:
|
||||
{
|
||||
rogMode.value = 0;
|
||||
//print("-- rog mode is ctrl is ${rog_mode.value}");
|
||||
@ -117,24 +110,13 @@ class IndexController extends GetxController {
|
||||
default:
|
||||
{
|
||||
rogMode.value = 0;
|
||||
Get.toNamed(AppPages.INITIAL);
|
||||
Get.toNamed(AppPages.INDEX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
//_ever = ever(rogMode, (_) => print("$_ has been changed (ever)"));
|
||||
|
||||
// if (perfectures.isEmpty) {
|
||||
// PerfectureService.loadPerfectures().then((value) {
|
||||
// perfectures.add(value);
|
||||
// loadAreaFor("9");
|
||||
|
||||
// //loadSubPerfFor("9");
|
||||
// });
|
||||
// }
|
||||
|
||||
_connectivitySubscription =
|
||||
_connectivity.onConnectivityChanged.listen(_updateConnectionStatus);
|
||||
super.onInit();
|
||||
@ -181,19 +163,6 @@ class IndexController extends GetxController {
|
||||
return LatLngBounds(LatLng(x1!, y1!), LatLng(x0!, y0!));
|
||||
}
|
||||
|
||||
List<LatLng> getLocationsList() {
|
||||
List<LatLng> locs = [];
|
||||
for (int i = 0; i <= locations[0].collection.length - 1; i++) {
|
||||
GeoJsonMultiPoint p =
|
||||
locations[0].collection[i].geometry as GeoJsonMultiPoint;
|
||||
|
||||
LatLng latLng = LatLng(p.geoSerie!.geoPoints[0].latitude,
|
||||
p.geoSerie!.geoPoints[0].longitude);
|
||||
locs.add(latLng);
|
||||
}
|
||||
return locs;
|
||||
}
|
||||
|
||||
void login(String email, String password, BuildContext context) {
|
||||
AuthService.login(email, password).then((value) {
|
||||
//print("------- logged in user details ######## $value ###### --------");
|
||||
@ -228,7 +197,7 @@ class IndexController extends GetxController {
|
||||
if (rogMode.value == 1) {
|
||||
switchPage(AppPages.TRAVEL);
|
||||
} else {
|
||||
switchPage(AppPages.INITIAL);
|
||||
switchPage(AppPages.INDEX);
|
||||
}
|
||||
} else {
|
||||
Get.snackbar(
|
||||
@ -264,7 +233,7 @@ class IndexController extends GetxController {
|
||||
currentUser.add(value);
|
||||
isLoading.value = false;
|
||||
Navigator.pop(context);
|
||||
Get.toNamed(AppPages.INITIAL);
|
||||
Get.toNamed(AppPages.INDEX);
|
||||
} else {
|
||||
isLoading.value = false;
|
||||
Get.snackbar(
|
||||
@ -299,7 +268,7 @@ class IndexController extends GetxController {
|
||||
} else {
|
||||
rogMode.value = 1;
|
||||
}
|
||||
Get.toNamed(AppPages.INITIAL);
|
||||
Get.toNamed(AppPages.INDEX);
|
||||
}
|
||||
|
||||
loadUserDetailsForToken(String token) async {
|
||||
@ -370,18 +339,6 @@ class IndexController extends GetxController {
|
||||
currentBound.add(bounds);
|
||||
}
|
||||
|
||||
void zoomtoSubPerf(String id) {
|
||||
////print("zooooom");
|
||||
|
||||
PerfectureService.getSubExt(id).then((value) {
|
||||
LatLng lat1 = LatLng(value![1], value[0]);
|
||||
LatLng lat2 = LatLng(value[3], value[2]);
|
||||
LatLngBounds bound = LatLngBounds(lat1, lat2);
|
||||
mapController.fitBounds(bound);
|
||||
setBound(bound);
|
||||
});
|
||||
}
|
||||
|
||||
GeoJsonFeature? getFeatureForLatLong(double lat, double long) {
|
||||
if (locations.isNotEmpty) {
|
||||
for (GeoJsonFeature i in locations[0].collection) {
|
||||
|
||||
@ -26,7 +26,7 @@ part 'app_routes.dart';
|
||||
|
||||
class AppPages {
|
||||
// ignore: constant_identifier_names
|
||||
static const INITIAL = Routes.INDEX;
|
||||
static const INDEX = Routes.INDEX;
|
||||
// ignore: constant_identifier_names
|
||||
static const SPA = Routes.SPA;
|
||||
static const LANDING = Routes.LANDING;
|
||||
|
||||
Reference in New Issue
Block a user