optimized and removed travel mode
This commit is contained in:
@ -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;
|
||||
@ -110,7 +105,7 @@ class DestinationController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> startTimerLocation(GeoJsonFeature fs, double distance) async {
|
||||
// print("---- in startTimer ----");
|
||||
//print("---- in startTimer ----");
|
||||
// print("---- is in rog is $is_in_rog ----");
|
||||
double checkinRadious = fs.properties!['checkin_radius'] ?? double.infinity;
|
||||
if (checkinRadious >= distance) {
|
||||
@ -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 ----");
|
||||
|
||||
Reference in New Issue
Block a user