added disabled feature to buttons and reset on start

This commit is contained in:
2024-02-26 20:23:58 +05:30
parent c3cb6d758c
commit 992f9f3414
5 changed files with 169 additions and 452 deletions

View File

@ -396,45 +396,6 @@ class StartRogaining extends StatelessWidget {
}
}
// class NotAtGoal extends StatelessWidget {
// NotAtGoal({Key? key}) : super(key: key);
// DestinationController destinationController =
// Get.find<DestinationController>();
// @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;

View File

@ -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;
}

View File

@ -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.
),
),
),
),
],
),
],
),
],

View File

@ -202,13 +202,13 @@ class ExternalService {
'image': ""
}),
);
var vvv = jsonEncode(<String, String>{
'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(<String, String>{
// '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) {

View File

@ -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,63 +206,23 @@ 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 &&
// Finish or Goal
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red),
onPressed: destinationController
.rogainingCounted.value ==
true &&
destinationController.distanceToStart() <=
500 &&
destination.cp == -1 &&
//destination.cp == -1 &&
DestinationController.ready_for_goal == true
? ElevatedButton(
onPressed: () async {
? () async {
destinationController.isAtGoal.value = true;
destinationController.photos.clear();
await showModalBottomSheet(
constraints: BoxConstraints.loose(ui.Size(
constraints: BoxConstraints.loose(
ui.Size(
Get.width, Get.height * 0.75)),
context: Get.context!,
isScrollControlled: true,
@ -527,12 +234,15 @@ class BottomSheetNew extends GetView<BottomSheetController> {
destinationController.isAtGoal.value =
false;
});
},
child: Text("ロゲイニングを終える"))
: Container(),
}
: 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,15 +262,19 @@ class BottomSheetNew extends GetView<BottomSheetController> {
backgroundColor: Theme.of(context)
.colorScheme
.onPrimaryContainer),
onPressed: () async {
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,
desiredAccuracy: LocationAccuracy
.bestForNavigation,
forceAndroidLocationManager: true);
//print("------- position -------- $position");
Destination ds = Destination(
@ -599,8 +286,11 @@ class BottomSheetNew extends GetView<BottomSheetController> {
lon: mp.coordinates[0][0]);
destinationController
.destinationMatrixFromCurrentPoint([ds, tp]);
},
.destinationMatrixFromCurrentPoint(
[ds, tp]);
}
: null,
//go here
child: Text(
"ここへ行く",
style: TextStyle(
@ -617,27 +307,59 @@ class BottomSheetNew extends GetView<BottomSheetController> {
.getForcedChckinDistance(destination)
? Obx(() => ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context)
.colorScheme
.secondary),
backgroundColor:
Theme.of(context).colorScheme.secondary,
),
onPressed: () async {
//print("~~~~ manual checkin button ~~~~");
// Check conditions to show confirmation dialog
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!);
// 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();
ExternalService()
.startRogaining()
.then((value) => Get.back());
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;
}
@ -665,7 +387,9 @@ class BottomSheetNew extends GetView<BottomSheetController> {
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onSecondary))))
.onSecondary),
),
))
: Container(),
],
),