update goal condition for more that 1000 m away

This commit is contained in:
2024-01-18 19:58:00 +05:30
parent 2fb095bd50
commit b9e4df069f
3 changed files with 11 additions and 1 deletions

View File

@ -15,6 +15,7 @@ void saveGameState() async {
pref.setBool("is_in_rog", destinationController.isInRog.value); pref.setBool("is_in_rog", destinationController.isInRog.value);
pref.setBool( pref.setBool(
"rogaining_counted", destinationController.rogainingCounted.value); "rogaining_counted", destinationController.rogainingCounted.value);
pref.setBool("ready_for_goal", DestinationController.ready_for_goal);
} }
void restoreGame() async { void restoreGame() async {
@ -25,6 +26,8 @@ void restoreGame() async {
destinationController.isInRog.value = pref.getBool("is_in_rog") ?? false; destinationController.isInRog.value = pref.getBool("is_in_rog") ?? false;
destinationController.rogainingCounted.value = destinationController.rogainingCounted.value =
pref.getBool("rogaining_counted") ?? false; pref.getBool("rogaining_counted") ?? false;
DestinationController.ready_for_goal =
pref.getBool("ready_for_goal") ?? false;
//print( //print(
// "--restored -- destinationController.isInRog.value ${pref.getBool("is_in_rog")} -- ${pref.getBool("rogaining_counted")}"); // "--restored -- destinationController.isInRog.value ${pref.getBool("is_in_rog")} -- ${pref.getBool("rogaining_counted")}");
} }

View File

@ -46,6 +46,7 @@ class DestinationController extends GetxController {
static bool gps_push_started = false; static bool gps_push_started = false;
static bool game_started = false; static bool game_started = false;
static bool ready_for_goal = false;
bool skip_10s = false; bool skip_10s = false;
@ -420,6 +421,7 @@ class DestinationController extends GetxController {
isAtGoal.value = false; isAtGoal.value = false;
isGpsSelected.value = true; isGpsSelected.value = true;
skipGps = false; skipGps = false;
ready_for_goal = false;
_start = 0; _start = 0;
chekcs = 0; chekcs = 0;
@ -744,6 +746,10 @@ class DestinationController extends GetxController {
void handleLocationUpdate(Position? position) async { void handleLocationUpdate(Position? position) async {
if (position != null) { if (position != null) {
if (distanceToStart() >= 1000) {
ready_for_goal = true;
}
var distance = const Distance(); var distance = const Distance();
double distanceToDest = distance.as( double distanceToDest = distance.as(
LengthUnit.Meter, LengthUnit.Meter,

View File

@ -508,7 +508,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
destinationController.rogainingCounted.value == true && destinationController.rogainingCounted.value == true &&
destinationController.distanceToStart() <= destinationController.distanceToStart() <=
500 && 500 &&
destination.cp == -1 destination.cp == -1 &&
DestinationController.ready_for_goal == true
? ElevatedButton( ? ElevatedButton(
onPressed: () async { onPressed: () async {
destinationController.isAtGoal.value = true; destinationController.isAtGoal.value = true;