updated progress indicator for goal

This commit is contained in:
Mohamed Nouffer
2023-07-16 00:17:42 +05:30
parent 547891437b
commit c756c4a5be

View File

@ -14,6 +14,8 @@ class CameraPage extends StatelessWidget {
DestinationController destinationController = Get.find<DestinationController>(); DestinationController destinationController = Get.find<DestinationController>();
IndexController indexController = Get.find<IndexController>(); IndexController indexController = Get.find<IndexController>();
var settingGoal = false.obs;
Timer? timer; Timer? timer;
ImageProvider getFinishImage(){ ImageProvider getFinishImage(){
@ -25,51 +27,70 @@ class CameraPage extends StatelessWidget {
} }
} }
Widget getAction(BuildContext context){ Widget getAction(BuildContext context) {
if(destinationController.is_at_goal.value && destinationController.is_in_rog.value){ if(destinationController.is_at_goal.value && destinationController.is_in_rog.value){
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [ children: [
ElevatedButton( ElevatedButton(
onPressed: (){ onPressed: (){
destinationController.openCamera(context); if(settingGoal.value ==false){
destinationController.openCamera(context);
}
}, },
child: Text("take_photo of the clock".tr) child: Text("take_photo of the clock".tr)
), ),
Obx(() => Obx(() =>
destinationController.photos.isNotEmpty ? destinationController.photos.isNotEmpty ?
ElevatedButton( settingGoal.value == false ?
style: ElevatedButton.styleFrom( ElevatedButton(
primary: Colors.red style: ElevatedButton.styleFrom(
), primary: Colors.red
onPressed: (){ ),
int user_id = indexController.currentUser[0]["user"]["id"]; onPressed: () async {
//print("--- Pressed -----"); settingGoal.value = true;
String _team = indexController.currentUser[0]["user"]['team_name']; try{
//print("--- _team : ${_team}-----"); int user_id = indexController.currentUser[0]["user"]["id"];
String _event_code = indexController.currentUser[0]["user"]["event_code"]; //print("--- Pressed -----");
//print("--- _event_code : ${_event_code}-----"); String _team = indexController.currentUser[0]["user"]['team_name'];
String _token = indexController.currentUser[0]["token"]; //print("--- _team : ${_team}-----");
//print("--- _token : ${_token}-----"); String _event_code = indexController.currentUser[0]["user"]["event_code"];
DateTime now = DateTime.now(); //print("--- _event_code : ${_event_code}-----");
String formattedDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(now); String _token = indexController.currentUser[0]["token"];
//print("--- _token : ${_token}-----");
ExternalService().makeGoal(user_id, _token, _team, destinationController.photos[0].path, formattedDate, _event_code).then((value){ DateTime now = DateTime.now();
print("---called ext api ${value['status']} ------"); String formattedDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(now);
if(value['status'] == 'OK'){
Get.back(); await ExternalService().makeGoal(user_id, _token, _team, destinationController.photos[0].path, formattedDate, _event_code).then((value){
destinationController.skip_gps = false; print("---called ext api ${value['status']} ------");
Get.snackbar("目標が保存されました", "目標が正常に追加されました"); if(value['status'] == 'OK'){
destinationController.resetRogaining(); Get.back();
} destinationController.skip_gps = false;
else{ Get.snackbar("目標が保存されました", "目標が正常に追加されました");
print("---- status ${value['status']} ---- "); destinationController.resetRogaining();
Get.snackbar("目標が追加されていません", "please_try_again"); }
} else{
}); print("---- status ${value['status']} ---- ");
}, Get.snackbar("目標が追加されていません", "please_try_again");
child: Text("finish_goal".tr) }
): });
}
on Exception catch(_){
settingGoal.value = false;
}
finally{
settingGoal.value = false;
}
},
child:Text("finish_goal".tr)
)
:
Container(
child: Center(
child: CircularProgressIndicator(),
),
)
:
Container() Container()
) )
], ],