added disabled feature to buttons and reset on start
This commit is contained in:
@ -112,6 +112,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
|
||||
@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<BottomSheetController> {
|
||||
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<Widget>(
|
||||
// // future: wantToGo(context),
|
||||
// // builder: (context, snapshot) {
|
||||
// // return Container(
|
||||
// // child: snapshot.data,
|
||||
// // );
|
||||
// // },
|
||||
// // ),
|
||||
|
||||
// // ),
|
||||
// const SizedBox(
|
||||
// height: 60.0,
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
Future<bool> isDestinationCheckedIn(Destination d) async {
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
List<Destination> ds = await db.getDestinationByLatLon(d.lat!, d.lon!);
|
||||
@ -459,80 +206,43 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
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<BottomSheetController> {
|
||||
.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<BottomSheetController> {
|
||||
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<BottomSheetController> {
|
||||
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: <Widget>[
|
||||
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<BottomSheetController> {
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSecondary))))
|
||||
.onSecondary),
|
||||
),
|
||||
))
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user