diff --git a/lib/pages/camera/camera_page.dart b/lib/pages/camera/camera_page.dart index de7e6c3..df79b7e 100644 --- a/lib/pages/camera/camera_page.dart +++ b/lib/pages/camera/camera_page.dart @@ -396,45 +396,6 @@ class StartRogaining extends StatelessWidget { } } -// class NotAtGoal extends StatelessWidget { -// NotAtGoal({Key? key}) : super(key: key); - -// DestinationController destinationController = -// Get.find(); - -// @override -// Widget build(BuildContext context) { -// return Scaffold( -// appBar: AppBar( -// title: Text( -// "Not reached the goal yet".tr, -// ), -// ), -// body: Container( -// child: Center( -// child: Column( -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// Text("You have not reached the goal yet.".tr, -// style: const TextStyle(fontSize: 24)), -// const SizedBox( -// height: 40.0, -// ), -// ElevatedButton( -// onPressed: () { -// Get.back(); -// destinationController.skip_gps = false; -// }, -// child: const Text("Back"), -// ), -// ], -// ), -// ), -// ), -// ); -// } -// } - class BuyPointCamera extends StatelessWidget { BuyPointCamera({Key? key, required this.destination}) : super(key: key); @@ -445,6 +406,8 @@ class BuyPointCamera extends StatelessWidget { @override Widget build(BuildContext context) { + print("in camera purchase 1 ${destinationController.isInRog.value}"); + return Scaffold( appBar: AppBar( automaticallyImplyLeading: false, @@ -482,6 +445,8 @@ class BuyPointCamera extends StatelessWidget { children: [ ElevatedButton( onPressed: () { + print( + "in camera purchase 2 ${destinationController.isInRog.value}"); destinationController.openCamera( context, destination); }, @@ -520,10 +485,14 @@ class BuyPointCamera extends StatelessWidget { style: ElevatedButton.styleFrom( backgroundColor: Colors.red), onPressed: () async { + print( + "in camera purchase 3 ${destinationController.isInRog.value}"); await destinationController.makeBuyPoint( destination, destinationController.photos[0].path); Get.back(); + print( + "in camera purchase 4 ${destinationController.isInRog.value}"); destinationController.rogainingCounted.value = true; destinationController.skipGps = false; diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index 7e1b521..4ba9d89 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -430,6 +430,10 @@ class DestinationController extends GetxController { rogainingCounted.value = false; DatabaseHelper db = DatabaseHelper.instance; + + await db.deleteAllDestinations(); + await db.deleteAllRogaining(); + int? latgoal = await db.latestGoal(); if (latgoal != null) { lastGoalAt = DateTime.fromMicrosecondsSinceEpoch(latgoal); @@ -794,6 +798,8 @@ class DestinationController extends GetxController { orElse: () => null, // Provide a null value if no element is found ); + //print("gfs : ${gfs}"); + if (gfs == null) { return distanceToDest; } diff --git a/lib/pages/login/login_page.dart b/lib/pages/login/login_page.dart index 5983bce..ff1c687 100644 --- a/lib/pages/login/login_page.dart +++ b/lib/pages/login/login_page.dart @@ -209,7 +209,25 @@ class LoginPage extends StatelessWidget { ), ), ], - ) + ), + const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Flexible( + child: Padding( + padding: EdgeInsets.all(8.0), + child: Text( + "※第8回と第9回は、岐阜県からの「清流の国ぎふ」SDGs推進ネットワーク連携促進補助金を受けています", + style: TextStyle( + fontSize: + 12, // Consider adjusting the font size if the text is too small. + // Removed overflow: TextOverflow.ellipsis to allow text wrapping. + ), + ), + ), + ), + ], + ), ], ), ], diff --git a/lib/services/external_service.dart b/lib/services/external_service.dart index 8dc72ef..fc40ad6 100644 --- a/lib/services/external_service.dart +++ b/lib/services/external_service.dart @@ -202,13 +202,13 @@ class ExternalService { 'image': "" }), ); - var vvv = jsonEncode({ - 'team_name': teamname, - 'cp_number': cp.toString(), - 'event_code': eventcode, - 'image': res["checkinimage"].toString().replaceAll( - 'http://localhost:8100', 'http://rogaining.sumasen.net') - }); + // var vvv = jsonEncode({ + // 'team_name': teamname, + // 'cp_number': cp.toString(), + // 'event_code': eventcode, + // 'image': res["checkinimage"].toString().replaceAll( + // 'http://localhost:8100', 'http://rogaining.sumasen.net') + // }); // print("--json-- $vvv"); // print("--- checnin response ${response3.statusCode}----"); if (response3.statusCode == 200) { diff --git a/lib/widgets/bottom_sheet_new.dart b/lib/widgets/bottom_sheet_new.dart index ada27cd..e81f26a 100644 --- a/lib/widgets/bottom_sheet_new.dart +++ b/lib/widgets/bottom_sheet_new.dart @@ -112,6 +112,8 @@ class BottomSheetNew extends GetView { @override Widget build(BuildContext context) { + print("to start ${destinationController.distanceToStart()}"); + destinationController.skipGps = true; // print('--- c use --- ${indexController.currentUser[0].values}'); // print('---- rog_mode ----- ${indexController.rogMode.value} -----'); @@ -121,261 +123,6 @@ class BottomSheetNew extends GetView { return detailsSheet(context); } - // Show destination detais - // SingleChildScrollView destinationSheet(BuildContext context) { - // // print( - // // '---- currentDestinationFeature ----- ${indexController.currentDestinationFeature[0].name} -----'); - - // return SingleChildScrollView( - // child: Column( - // children: [ - // Padding( - // padding: const EdgeInsets.all(8.0), - // child: Row( - // children: [ - // MaterialButton( - // onPressed: () { - // Get.back(); - // //destinationController.makePrevious(indexController.currentDestinationFeature[0]); - // }, - // color: Colors.blue, - // textColor: Colors.white, - // padding: const EdgeInsets.all(16), - // shape: const CircleBorder(), - // child: const Icon( - // Icons.arrow_back_ios, - // size: 14, - // ), - // ), - // Expanded( - // child: Container( - // alignment: Alignment.center, - // child: Obx(() => indexController.currentUser.isNotEmpty - // ? Text( - // "${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${TextUtils.getDisplayText(indexController.currentDestinationFeature[0])} : ${indexController.currentDestinationFeature[0].name!}", - // style: const TextStyle( - // fontSize: 15.0, - // fontWeight: FontWeight.bold, - // ), - // ) - // : Text( - // indexController.currentDestinationFeature[0].name!, - // style: const TextStyle( - // fontSize: 15.0, - // fontWeight: FontWeight.bold, - // ), - // )), - // ), - // ), - // ], - // ), - // ), - // Row( - // children: [ - // Expanded( - // child: SizedBox( - // height: 260.0, - // child: Obx(() => getImage()), - // )), - // ], - // ), - // Row( - // mainAxisAlignment: MainAxisAlignment.spaceAround, - // children: [ - // Obx( - // () => indexController.currentDestinationFeature.isNotEmpty && - // destinationController.isInCheckin.value == true && - // destinationController.isAtStart.value == false - // ? Row( - // children: [ - // ElevatedButton( - // onPressed: () { - // if (indexController.currentDestinationFeature[0] - // .checkedin == - // null || - // indexController.currentDestinationFeature[0] - // .checkedin == - // false) { - // if (indexController - // .currentDestinationFeature[0] - // .hidden_location == - // 0) { - // destinationController.skipGps = false; - // destinationController.isPhotoShoot.value = - // true; - // Get.back(); - // } else { - // destinationController.makeCheckin( - // indexController - // .currentDestinationFeature[0], - // true, - // ""); - // if (indexController - // .currentDestinationFeature[0].cp != - // -1) { - // destinationController - // .rogainingCounted.value = true; - // } - // } - // } else { - // destinationController.makeCheckin( - // indexController - // .currentDestinationFeature[0], - // false, - // ""); - // } - // //Get.back(); - // }, - // child: Text( - // //Checkin - // indexController.currentDestinationFeature[0] - // .checkedin == - // null || - // indexController - // .currentDestinationFeature[0] - // .checkedin == - // false - // ? "チェックイン" - // : "チェックアウト")), - // ], - // ) - // : Container(), - // ), - // Obx( - // () => destinationController.isAtStart.value == true - // ? ElevatedButton( - // onPressed: () { - // destinationController.isInRog.value = true; - // destinationController.addToRogaining( - // destinationController.currentLat, - // destinationController.currentLon, - // indexController - // .currentDestinationFeature[0].location_id!); - // saveGameState(); - // ExternalService() - // .startRogaining() - // .then((value) => Get.back()); - // }, - // child: Text( - // // start - // indexController.currentDestinationFeature[0] - // .checkedin != - // null || - // indexController.currentDestinationFeature[0] - // .checkedin == - // true - // ? "ロゲイニングを開始" - // : "間違った目的地...")) - // : Container(), - // ), - // Obx( - // () => destinationController.isAtGoal.value == true && - // destinationController.rogainingCounted.value == true - // ? ElevatedButton( - // onPressed: () { - // Get.toNamed(AppPages.CAMERA_PAGE); - // Get.back(); - // }, - // child: Text( - // //goal - // indexController.currentDestinationFeature[0] - // .checkedin != - // null || - // indexController.currentDestinationFeature[0] - // .checkedin == - // true - // ? "ロゲイニングを終える" - // : "間違った目的地 ...")) - // : Container(), - // ), - // ], - // ), - // Obx( - // () => indexController.currentDestinationFeature[0].address != - // null && - // indexController - // .currentDestinationFeature[0].address!.isNotEmpty - // ? getDetails(context, "address".tr, - // indexController.currentDestinationFeature[0].address! ?? '') - // : const SizedBox( - // width: 0.0, - // height: 0, - // ), - // ), - // Obx( - // () => indexController.currentDestinationFeature[0].phone != null && - // indexController - // .currentDestinationFeature[0].phone!.isNotEmpty - // ? getDetails(context, "telephone".tr, - // indexController.currentDestinationFeature[0].phone! ?? '') - // : const SizedBox( - // width: 0.0, - // height: 0, - // ), - // ), - // Obx( - // () => indexController.currentDestinationFeature[0].email != null && - // indexController - // .currentDestinationFeature[0].email!.isNotEmpty - // ? getDetails(context, "email".tr, - // indexController.currentDestinationFeature[0].email! ?? '') - // : const SizedBox( - // width: 0.0, - // height: 0, - // ), - // ), - // Obx( - // () => indexController.currentDestinationFeature[0].webcontents != - // null && - // indexController - // .currentDestinationFeature[0].webcontents!.isNotEmpty - // ? getDetails( - // context, - // "web".tr, - // indexController.currentDestinationFeature[0].webcontents! ?? - // '', - // isurl: true) - // : const SizedBox( - // width: 0.0, - // height: 0, - // ), - // ), - // Obx( - // () => indexController.currentDestinationFeature[0].videos != null && - // indexController - // .currentDestinationFeature[0].videos!.isNotEmpty - // ? getDetails(context, "video".tr, - // indexController.currentDestinationFeature[0].videos! ?? '', - // isurl: true) - // : const SizedBox( - // width: 0.0, - // height: 0, - // ), - // ), - // const SizedBox( - // height: 20.0, - // ), - // // Obx(() => - // // //wantToGo(context), - - // // FutureBuilder( - // // future: wantToGo(context), - // // builder: (context, snapshot) { - // // return Container( - // // child: snapshot.data, - // // ); - // // }, - // // ), - - // // ), - // const SizedBox( - // height: 60.0, - // ) - // ], - // ), - // ); - // } - Future isDestinationCheckedIn(Destination d) async { DatabaseHelper db = DatabaseHelper.instance; List ds = await db.getDestinationByLatLon(d.lat!, d.lon!); @@ -459,80 +206,43 @@ class BottomSheetNew extends GetView { Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - // Obx( - // () => indexController - // .currentDestinationFeature.isNotEmpty && - // indexController - // .currentDestinationFeature[0].cp == - // -1 && - // indexController.currentDestinationFeature[0] - // .checkedin == - // false && - // destinationController.isAtStart.value == true - // ? ElevatedButton( - // onPressed: () async { - // await destinationController - // .resetRogaining(); - // //print("~~~~ start button ~~~~"); - // destinationController.isInRog.value = true; - // destinationController.addToRogaining( - // destinationController.currentLat, - // destinationController.currentLon, - // indexController - // .currentDestinationFeature[0] - // .location_id!); - // saveGameState(); - // ExternalService() - // .startRogaining() - // .then((value) { - // Get.back(); - // }); - // }, - // child: Text( - // // start - // indexController - // .currentDestinationFeature[ - // 0] - // .checkedin != - // null || - // indexController - // .currentDestinationFeature[ - // 0] - // .checkedin == - // true - // ? "ロゲイニングを開始" - // : "間違った目的地...")) - // : Container(), - // ), - - destinationController.rogainingCounted.value == true && - destinationController.distanceToStart() <= - 500 && - destination.cp == -1 && - DestinationController.ready_for_goal == true - ? ElevatedButton( - onPressed: () async { - destinationController.isAtGoal.value = true; - destinationController.photos.clear(); - await showModalBottomSheet( - constraints: BoxConstraints.loose(ui.Size( - Get.width, Get.height * 0.75)), - context: Get.context!, - isScrollControlled: true, - builder: ((context) => CameraPage( - destination: destination, - ))).whenComplete(() { - destinationController.skipGps = false; - destinationController.chekcs = 0; - destinationController.isAtGoal.value = - false; - }); - }, - child: Text("ロゲイニングを終える")) - : Container(), + // Finish or Goal + ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red), + onPressed: destinationController + .rogainingCounted.value == + true && + destinationController.distanceToStart() <= + 500 && + //destination.cp == -1 && + DestinationController.ready_for_goal == true + ? () async { + destinationController.isAtGoal.value = true; + destinationController.photos.clear(); + await showModalBottomSheet( + constraints: BoxConstraints.loose( + ui.Size( + Get.width, Get.height * 0.75)), + context: Get.context!, + isScrollControlled: true, + builder: ((context) => CameraPage( + destination: destination, + ))).whenComplete(() { + destinationController.skipGps = false; + destinationController.chekcs = 0; + destinationController.isAtGoal.value = + false; + }); + } + : null, + child: const Text("ロゲイニングを終える")) // goal + , //remove checkin isAlreadyCheckedIn == true && destination.cp != -1 ? ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.blueAccent), onPressed: () async { await destinationController .removeCheckin(destination.cp!.toInt()); @@ -540,35 +250,8 @@ class BottomSheetNew extends GetView { .deleteDestination(destination); Get.back(); }, - child: const Text("チェックイン取消")) + child: const Text("チェックイン取消")) //remove checkin : 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( @@ -579,28 +262,35 @@ class BottomSheetNew extends GetView { backgroundColor: Theme.of(context) .colorScheme .onPrimaryContainer), - onPressed: () async { - Get.back(); - //print("---- go to ----"); - GeoJSONMultiPoint mp = indexController - .currentFeature[0] as GeoJSONMultiPoint; - Position position = - await Geolocator.getCurrentPosition( - desiredAccuracy: - LocationAccuracy.bestForNavigation, - forceAndroidLocationManager: true); - //print("------- position -------- $position"); - Destination ds = Destination( - lat: position.latitude, - lon: position.longitude); + onPressed: destinationController.distanceToStart() > + 500 + ? () async { + print( + "dist to start ${destinationController.distanceToStart()}"); + Get.back(); + //print("---- go to ----"); + GeoJSONMultiPoint mp = indexController + .currentFeature[0] as GeoJSONMultiPoint; + Position position = + await Geolocator.getCurrentPosition( + desiredAccuracy: LocationAccuracy + .bestForNavigation, + forceAndroidLocationManager: true); + //print("------- position -------- $position"); + Destination ds = Destination( + lat: position.latitude, + lon: position.longitude); - Destination tp = Destination( - lat: mp.coordinates[0][1], - lon: mp.coordinates[0][0]); + Destination tp = Destination( + lat: mp.coordinates[0][1], + lon: mp.coordinates[0][0]); - destinationController - .destinationMatrixFromCurrentPoint([ds, tp]); - }, + destinationController + .destinationMatrixFromCurrentPoint( + [ds, tp]); + } + : null, + //go here child: Text( "ここへ行く", style: TextStyle( @@ -616,37 +306,69 @@ class BottomSheetNew extends GetView { destinationController .getForcedChckinDistance(destination) ? Obx(() => ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Theme.of(context) - .colorScheme - .secondary), - onPressed: () async { - //print("~~~~ manual checkin button ~~~~"); - if (destination.cp == -1 && - destinationController.isInRog.value == - false && - destinationController - .rogainingCounted.value == - false) { - destinationController.isInRog.value = true; - destinationController.addToRogaining( - destinationController.currentLat, - destinationController.currentLon, - destination.location_id!); - saveGameState(); - ExternalService() - .startRogaining() - .then((value) => Get.back()); - } else { - if (destination.cp == -1) { - return; + style: ElevatedButton.styleFrom( + backgroundColor: + Theme.of(context).colorScheme.secondary, + ), + onPressed: () async { + // Check conditions to show confirmation dialog + if (destination.cp == -1 && + destinationController.isInRog.value == + false && + destinationController + .rogainingCounted.value == + false) { + // Show confirmation dialog + Get.dialog( + AlertDialog( + title: const Text("確認"), //confirm + content: const Text( + "ロゲを開始すると、今までのロゲデータが全てクリアされます。本当に開始しますか?"), //are you sure + actions: [ + TextButton( + child: const Text("いいえ"), //no + onPressed: () { + Get.back(); // Close the dialog + }, + ), + TextButton( + child: const Text("はい"), //yes + onPressed: () async { + // Clear data and start game logic here + destinationController + .isInRog.value = true; + destinationController + .resetRogaining(); // Assuming you have a method to clear data + destinationController + .addToRogaining( + destinationController + .currentLat, + destinationController + .currentLon, + destination.location_id!, + ); + saveGameState(); + await ExternalService() + .startRogaining(); + Get.back(); // Close the dialog and potentially navigate away + }, + ), + ], + ), + barrierDismissible: + false, // User must tap a button to close the dialog + ); + } else { + // Existing logic for other conditions + if (destination.cp == -1) { + return; + } + Get.back(); + await destinationController + .callforCheckin(destination); } - Get.back(); - await destinationController - .callforCheckin(destination); - } - }, - child: Text( + }, + child: Text( destination.cp == -1 && destinationController .isInRog.value == @@ -665,7 +387,9 @@ class BottomSheetNew extends GetView { style: TextStyle( color: Theme.of(context) .colorScheme - .onSecondary)))) + .onSecondary), + ), + )) : Container(), ], ),