diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index 02c7034..1696e04 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -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; } diff --git a/lib/utils/database_helper.dart b/lib/utils/database_helper.dart index 018db48..987c2c8 100644 --- a/lib/utils/database_helper.dart +++ b/lib/utils/database_helper.dart @@ -237,6 +237,7 @@ class DatabaseHelper { } Future 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')); diff --git a/lib/widgets/bottom_sheet_new.dart b/lib/widgets/bottom_sheet_new.dart index 97a5955..44dc09e 100644 --- a/lib/widgets/bottom_sheet_new.dart +++ b/lib/widgets/bottom_sheet_new.dart @@ -109,9 +109,10 @@ class BottomSheetNew extends GetView { 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 { // : "間違った目的地...")) // : 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 { distanceToDest <= destinationController .getForcedChckinDistance(destination) && - destinationController.isInCheckin.value == - true && + // destinationController.isInCheckin.value == + // true && destinationController.rogainingCounted.value == false ? ElevatedButton(