diff --git a/lib/pages/camera/camera_page.dart b/lib/pages/camera/camera_page.dart index b3146f0..142a406 100644 --- a/lib/pages/camera/camera_page.dart +++ b/lib/pages/camera/camera_page.dart @@ -70,12 +70,54 @@ class CameraPage extends StatelessWidget { ); } else{ - return ElevatedButton( - child: Text("Checking image"), - onPressed: (){ - Get.back(); - }, - ); + return Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + ElevatedButton( + onPressed: (){ + destinationController.openCamera(context); + }, + child: Text("take checkin photo".tr) + ), + Obx(() => + destinationController.photos.isNotEmpty ? + ElevatedButton( + style: ElevatedButton.styleFrom( + primary: Colors.red + ), + onPressed: (){ + int user_id = indexController.currentUser[0]["user"]["id"]; + //print("--- Pressed -----"); + String _team = indexController.currentUser[0]["user"]['team_name']; + //print("--- _team : ${_team}-----"); + String _event_code = indexController.currentUser[0]["user"]["event_code"]; + //print("--- _event_code : ${_event_code}-----"); + String _token = indexController.currentUser[0]["token"]; + //print("--- _token : ${_token}-----"); + DateTime now = DateTime.now(); + String formattedDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(now); + + destinationController.makeCheckin(indexController.currentDestinationFeature[0], true); + + // ExternalService().makeGoal(user_id, _token, _team, destinationController.photos[0].path, formattedDate, _event_code).then((value){ + // print("---called ext api ${value['status']} ------"); + // if(value['status'] == 'OK'){ + // Get.back(); + // destinationController.skip_gps = false; + // Get.snackbar("Checked in", "Checked in successfuly"); + // } + // else{ + // print("---- status ${value['status']} ---- "); + // Get.snackbar("Checkin not added", "please_try_again"); + // } + // }); + }, + child: Text("Check In".tr) + ): + Container() + ) + ], + ); } } @@ -85,7 +127,7 @@ class CameraPage extends StatelessWidget { @override Widget build(BuildContext context) { - if(destinationController.is_at_goal.value){ + if(destinationController.is_in_rog.value){ return Scaffold( appBar: AppBar( title: Text("finishing_rogaining".tr), @@ -116,9 +158,6 @@ class CameraPage extends StatelessWidget { ), ); } - else if(destinationController.rogaining_counted.value == true) { - return NotAtGoal(); - } else { return StartRogaining(); } diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index d4d2dc5..b1a3686 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -148,6 +148,7 @@ class DestinationController extends GetxController { //start print("---- in start -----"); chekcs = 1; + is_in_checkin.value = true; is_at_start.value = true; showModalBottomSheet(context: Get.context!, isScrollControlled: true, builder:((context) => BottomSheetNew()) @@ -155,13 +156,14 @@ class DestinationController extends GetxController { skip_gps = false; chekcs = 0; is_at_start.value = false; + is_in_checkin.value = false; }); } - else + else if(is_in_rog.value == false) { print("----- in location popup checkin cp - ${d.cp}----"); chekcs = 2; - //is_in_checkin.value = true; + is_in_checkin.value = true; showModalBottomSheet(context: Get.context!, isScrollControlled: true, builder:((context) => BottomSheetNew()) ).whenComplete((){ @@ -185,8 +187,9 @@ class DestinationController extends GetxController { } } else{ + print("--- hidden loc ${d.hidden_location} ----"); // ask for checkin - if(d.hidden_location != null && d.hidden_location ==true && is_in_rog.value == true && d.cp != -1){ + if(d.hidden_location != null && d.hidden_location == 0 && is_in_rog.value == true && d.cp != -1){ chekcs = 3; is_in_checkin.value = true; showModalBottomSheet(context: Get.context!, isScrollControlled: true, @@ -217,7 +220,7 @@ class DestinationController extends GetxController { print("--- loc already checked in ${location_already_checked_in} ---"); if(isUser_logged_in && d.cp == -1 && location_already_checked_in){ //check for rogaining - if(is_at_goal.value == false && rogaining_counted.value){ + if(is_at_goal.value == false && rogaining_counted.value && indexController.rog_mode == 1){ //goal print("---- in goal -----"); chekcs = 5; @@ -230,7 +233,7 @@ class DestinationController extends GetxController { is_at_goal.value = false; }); } - else if(is_in_rog.value == false){ + else if(is_in_rog.value == false && indexController.rog_mode == 1){ //start print("---- in start -----"); chekcs = 6; diff --git a/lib/widgets/bottom_sheet_new.dart b/lib/widgets/bottom_sheet_new.dart index 65f4096..4b382dd 100644 --- a/lib/widgets/bottom_sheet_new.dart +++ b/lib/widgets/bottom_sheet_new.dart @@ -167,7 +167,7 @@ class BottomSheetNew extends GetView { mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Obx(() => - indexController.currentDestinationFeature.isNotEmpty && destinationController.is_in_checkin.value == true ? + indexController.currentDestinationFeature.isNotEmpty && destinationController.is_in_checkin.value == true && destinationController.is_at_start.value == false ? Row( children: [ ElevatedButton( @@ -340,13 +340,50 @@ class BottomSheetNew extends GetView { padding: const EdgeInsets.all(8.0), child: Column( children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Obx(() => + indexController.currentDestinationFeature.isNotEmpty && destinationController.is_in_checkin.value == true ? + Row( + children: [ + ElevatedButton( + onPressed: (){ + if(indexController.currentDestinationFeature[0].checkedin == null || indexController.currentDestinationFeature[0].checkedin == false){ + destinationController.makeCheckin(indexController.currentDestinationFeature[0], true); + if(indexController.currentDestinationFeature[0].cp != -1){ + destinationController.rogaining_counted.value =true; + } + } + else{ + destinationController.makeCheckin(indexController.currentDestinationFeature[0], false); + } + Get.back(); + }, + child: Text( + indexController.currentDestinationFeature[0].checkedin == null || indexController.currentDestinationFeature[0].checkedin == false ? + "Chekin" + : + "Checkput" + ) + ), + ], + ) + : + Container(), + ), + ], + ), Row( children: [ Expanded( child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ - FutureBuilder( + indexController.currentDestinationFeature.isNotEmpty && destinationController.is_in_checkin.value == true ? + Container() + : + FutureBuilder( future: wantToGo(context), builder: (context, snapshot) { return Container(