fixed start issue

This commit is contained in:
2023-11-21 15:45:03 +05:30
parent 3abd306e89
commit acc03f8e2b
3 changed files with 66 additions and 56 deletions

View File

@ -669,20 +669,19 @@ class DestinationController extends GetxController {
}
double distanceToStart() {
Destination? ds;
for (Destination d in destinations) {
if (d.cp == -1) {
ds = d;
}
}
//print("=== gfs len == ${indexController.locations[0].collection.length}");
GeoJsonFeature gfs = indexController.locations[0].collection
.firstWhere((element) => festuretoDestination(element).cp == -1);
Destination des = festuretoDestination(gfs);
//print("=== gfs == ${des.toMap()}");
double distanceToDest = double.infinity;
if (ds != null) {
var distance = const Distance();
distanceToDest = distance.as(LengthUnit.Meter,
LatLng(currentLat, currentLon), LatLng(ds.lat!, ds.lon!));
}
print("==== dist==${distanceToDest}");
var distance = const Distance();
distanceToDest = distance.as(LengthUnit.Meter,
LatLng(currentLat, currentLon), LatLng(des.lat!, des.lon!));
//print("==== dist==${distanceToDest}");
return distanceToDest;
}
@ -692,20 +691,17 @@ class DestinationController extends GetxController {
return 500;
}
Destination? ds;
for (Destination d in destinations) {
if (d.cp == -1) {
ds = d;
}
}
if (ds != null) {
var distance = const Distance();
double distanceToDest = distance.as(LengthUnit.Meter,
LatLng(dest.lat!, dest.lon!), LatLng(ds.lat!, ds.lon!));
if (distanceToDest <= 500) {
return 500;
}
}
GeoJsonFeature gfs = indexController.locations[0].collection
.firstWhere((element) => festuretoDestination(element).cp == -1);
ds = festuretoDestination(gfs);
var distance = const Distance();
double distanceToDest = distance.as(LengthUnit.Meter,
LatLng(dest.lat!, dest.lon!), LatLng(ds.lat!, ds.lon!));
if (distanceToDest <= 500) {
return 500;
}
print("==== forced dist ==${distanceToDest}");
return _retValue;
}

View File

@ -237,6 +237,7 @@ class DatabaseHelper {
}
Future<int> insertDestination(Destination dest) async {
await deleteDestination(dest.location_id!);
Database db = await instance.database;
int? nextOrder = Sqflite.firstIntValue(
await db.rawQuery('SELECT MAX(list_order) FROM destination'));

View File

@ -109,9 +109,10 @@ class BottomSheetNew extends GetView<BottomSheetController> {
destinationController.skipGps = true;
// print('--- c use --- ${indexController.currentUser[0].values}');
// print('---- rog_mode ----- ${indexController.rogMode.value} -----');
return indexController.rogMode.value == 0
? detailsSheet(context)
: destinationSheet(context);
// return indexController.rogMode.value == 0
// ? detailsSheet(context)
// : destinationSheet(context);
return detailsSheet(context);
}
// Show destination detais
@ -480,32 +481,44 @@ class BottomSheetNew extends GetView<BottomSheetController> {
// : "間違った目的地..."))
// : Container(),
// ),
Obx(
() => destinationController.rogainingCounted.value ==
true &&
destination.cp == -1 &&
destinationController.distanceToStart() <= 500
? ElevatedButton(
onPressed: () {
Get.toNamed(AppPages.CAMERA_PAGE);
Get.back();
},
child: Text(
//goal
indexController
.currentDestinationFeature[
0]
.checkedin !=
null ||
indexController
.currentDestinationFeature[
0]
.checkedin ==
true
? "ロゲイニングを終える"
: "間違った目的地 ..."))
: Container(),
),
destinationController.rogainingCounted.value == true &&
destination.cp == -1 &&
destinationController.distanceToStart() <= 500
? ElevatedButton(
onPressed: () {
Get.toNamed(AppPages.CAMERA_PAGE);
Get.back();
},
child: Text("ロゲイニングを終える"))
: Container(),
// Obx(
// () => destinationController.rogainingCounted.value ==
// false &&
// destination.cp == -1 &&
// destinationController.distanceToStart() <= 500
// ? ElevatedButton(
// onPressed: () {
// Get.toNamed(AppPages.CAMERA_PAGE);
// Get.back();
// },
// child: Text(
// //goal
// indexController
// .currentDestinationFeature[
// 0]
// .checkedin !=
// null ||
// indexController
// .currentDestinationFeature[
// 0]
// .checkedin ==
// true
// ? "ロゲイニングを終える"
// : "間違った目的地 ..."))
// : Container(),
// ),
],
),
Row(
@ -555,8 +568,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
distanceToDest <=
destinationController
.getForcedChckinDistance(destination) &&
destinationController.isInCheckin.value ==
true &&
// destinationController.isInCheckin.value ==
// true &&
destinationController.rogainingCounted.value ==
false
? ElevatedButton(