update to fix start after goal
This commit is contained in:
@ -51,6 +51,7 @@ class DestinationController extends GetxController {
|
|||||||
var is_at_start = false.obs;
|
var is_at_start = false.obs;
|
||||||
var is_at_goal = false.obs;
|
var is_at_goal = false.obs;
|
||||||
var is_photo_shoot = false.obs;
|
var is_photo_shoot = false.obs;
|
||||||
|
DateTime last_goal_at = DateTime.now().subtract(Duration(days:1));
|
||||||
//List<Rogaining> rogainings = <Rogaining>[].obs;
|
//List<Rogaining> rogainings = <Rogaining>[].obs;
|
||||||
|
|
||||||
bool checking_in = false;
|
bool checking_in = false;
|
||||||
@ -169,7 +170,7 @@ class DestinationController extends GetxController {
|
|||||||
List<Destination> ds = await db.getDestinationByLatLon(d.lat!, d.lon!);
|
List<Destination> ds = await db.getDestinationByLatLon(d.lat!, d.lon!);
|
||||||
if(ds.isEmpty){
|
if(ds.isEmpty){
|
||||||
print("----- in location popup cp - ${d.cp}----");
|
print("----- in location popup cp - ${d.cp}----");
|
||||||
if(d.cp == -1){
|
if(d.cp == -1 && DateTime.now().difference(last_goal_at).inHours >= 24){
|
||||||
chekcs = 1;
|
chekcs = 1;
|
||||||
//start
|
//start
|
||||||
print("---- in start -----");
|
print("---- in start -----");
|
||||||
@ -256,6 +257,7 @@ class DestinationController extends GetxController {
|
|||||||
print("--- at goal ${is_at_goal} ---");
|
print("--- at goal ${is_at_goal} ---");
|
||||||
print("--- rog counted ${rogaining_counted} ---");
|
print("--- rog counted ${rogaining_counted} ---");
|
||||||
print("--- loc already checked in ${location_already_checked_in} ---");
|
print("--- loc already checked in ${location_already_checked_in} ---");
|
||||||
|
print("==== date diff is ${DateTime.now().difference(last_goal_at).inHours} ====");
|
||||||
if(isUser_logged_in && d.cp == -1 && location_already_checked_in && skip_10s == false){
|
if(isUser_logged_in && d.cp == -1 && location_already_checked_in && skip_10s == false){
|
||||||
//check for rogaining
|
//check for rogaining
|
||||||
if(is_at_goal.value == false && rogaining_counted.value){
|
if(is_at_goal.value == false && rogaining_counted.value){
|
||||||
@ -272,7 +274,7 @@ class DestinationController extends GetxController {
|
|||||||
is_at_goal.value = false;
|
is_at_goal.value = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if(is_in_rog.value == false && indexController.rog_mode == 1){
|
else if(is_in_rog.value == false && indexController.rog_mode == 1 && DateTime.now().difference(last_goal_at).inHours >= 24){
|
||||||
//start
|
//start
|
||||||
print("---- in start -----");
|
print("---- in start -----");
|
||||||
chekcs = 6;
|
chekcs = 6;
|
||||||
@ -293,7 +295,7 @@ class DestinationController extends GetxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetRogaining(){
|
void resetRogaining() async {
|
||||||
print("----- resetting --------");
|
print("----- resetting --------");
|
||||||
|
|
||||||
is_in_checkin.value = false;
|
is_in_checkin.value = false;
|
||||||
@ -309,8 +311,14 @@ class DestinationController extends GetxController {
|
|||||||
chekcs = 0;
|
chekcs = 0;
|
||||||
rogaining_counted.value = false;
|
rogaining_counted.value = false;
|
||||||
|
|
||||||
|
|
||||||
DatabaseHelper db = DatabaseHelper.instance;
|
DatabaseHelper db = DatabaseHelper.instance;
|
||||||
|
int? _latgoal = await db.latestGoal();
|
||||||
|
if(_latgoal != null){
|
||||||
|
last_goal_at = DateTime.fromMicrosecondsSinceEpoch(_latgoal);
|
||||||
|
print("===== last goal : ${last_goal_at} =====");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
db.deleteAllDestinations().then((value){
|
db.deleteAllDestinations().then((value){
|
||||||
PopulateDestinations();
|
PopulateDestinations();
|
||||||
initGPS();
|
initGPS();
|
||||||
|
|||||||
@ -2,7 +2,9 @@ import 'dart:io';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:rogapp/model/destination.dart';
|
||||||
import 'package:rogapp/model/rog.dart';
|
import 'package:rogapp/model/rog.dart';
|
||||||
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||||
import 'package:rogapp/pages/index/index_controller.dart';
|
import 'package:rogapp/pages/index/index_controller.dart';
|
||||||
import 'package:rogapp/utils/database_helper.dart';
|
import 'package:rogapp/utils/database_helper.dart';
|
||||||
import 'package:sqflite/sqlite_api.dart';
|
import 'package:sqflite/sqlite_api.dart';
|
||||||
@ -190,8 +192,9 @@ class ExternalService {
|
|||||||
Map<String, dynamic> _res2 = {};
|
Map<String, dynamic> _res2 = {};
|
||||||
|
|
||||||
final IndexController indexController = Get.find<IndexController>();
|
final IndexController indexController = Get.find<IndexController>();
|
||||||
|
final DestinationController destinationController = Get.find<DestinationController>();
|
||||||
|
|
||||||
if(indexController.connectionStatusName != "wifi" && indexController.connectionStatusName != "mobile"){
|
//if(indexController.connectionStatusName != "wifi" && indexController.connectionStatusName != "mobile"){
|
||||||
DatabaseHelper db = DatabaseHelper.instance;
|
DatabaseHelper db = DatabaseHelper.instance;
|
||||||
Rog _rog = Rog(
|
Rog _rog = Rog(
|
||||||
id:1,
|
id:1,
|
||||||
@ -204,8 +207,8 @@ class ExternalService {
|
|||||||
rog_action_type: 1,
|
rog_action_type: 1,
|
||||||
);
|
);
|
||||||
db.insertRogaining(_rog);
|
db.insertRogaining(_rog);
|
||||||
}
|
// }
|
||||||
else{
|
// else{
|
||||||
String server_url = ConstValues.currentServer();
|
String server_url = ConstValues.currentServer();
|
||||||
String url1 = "${server_url}/api/goalimage/";
|
String url1 = "${server_url}/api/goalimage/";
|
||||||
final im1Bytes = File(image!).readAsBytesSync();
|
final im1Bytes = File(image!).readAsBytesSync();
|
||||||
@ -252,7 +255,8 @@ class ExternalService {
|
|||||||
_res2 = json.decode(utf8.decode(response2.bodyBytes));
|
_res2 = json.decode(utf8.decode(response2.bodyBytes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
|
destinationController.resetRogaining();
|
||||||
return _res2;
|
return _res2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -149,6 +149,12 @@ class DatabaseHelper{
|
|||||||
return rog.length > 0 ? true : false;
|
return rog.length > 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int?>latestGoal() async{
|
||||||
|
Database db = await instance.database;
|
||||||
|
return Sqflite.firstIntValue(await db.rawQuery('SELECT MAX(checkintime) FROM rog'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> insertRogaining(Rog rog) async {
|
Future<int> insertRogaining(Rog rog) async {
|
||||||
Database db = await instance.database;
|
Database db = await instance.database;
|
||||||
int? next_order = Sqflite.firstIntValue(await db.rawQuery('SELECT MAX(id) FROM rog'));
|
int? next_order = Sqflite.firstIntValue(await db.rawQuery('SELECT MAX(id) FROM rog'));
|
||||||
|
|||||||
Reference in New Issue
Block a user