updated progress indicator for goal
This commit is contained in:
@ -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,24 +27,29 @@ 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: (){
|
||||||
|
if(settingGoal.value ==false){
|
||||||
destinationController.openCamera(context);
|
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 ?
|
||||||
|
settingGoal.value == false ?
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
primary: Colors.red
|
primary: Colors.red
|
||||||
),
|
),
|
||||||
onPressed: (){
|
onPressed: () async {
|
||||||
|
settingGoal.value = true;
|
||||||
|
try{
|
||||||
int user_id = indexController.currentUser[0]["user"]["id"];
|
int user_id = indexController.currentUser[0]["user"]["id"];
|
||||||
//print("--- Pressed -----");
|
//print("--- Pressed -----");
|
||||||
String _team = indexController.currentUser[0]["user"]['team_name'];
|
String _team = indexController.currentUser[0]["user"]['team_name'];
|
||||||
@ -54,7 +61,7 @@ class CameraPage extends StatelessWidget {
|
|||||||
DateTime now = DateTime.now();
|
DateTime now = DateTime.now();
|
||||||
String formattedDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(now);
|
String formattedDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(now);
|
||||||
|
|
||||||
ExternalService().makeGoal(user_id, _token, _team, destinationController.photos[0].path, formattedDate, _event_code).then((value){
|
await ExternalService().makeGoal(user_id, _token, _team, destinationController.photos[0].path, formattedDate, _event_code).then((value){
|
||||||
print("---called ext api ${value['status']} ------");
|
print("---called ext api ${value['status']} ------");
|
||||||
if(value['status'] == 'OK'){
|
if(value['status'] == 'OK'){
|
||||||
Get.back();
|
Get.back();
|
||||||
@ -67,9 +74,23 @@ class CameraPage extends StatelessWidget {
|
|||||||
Get.snackbar("目標が追加されていません", "please_try_again");
|
Get.snackbar("目標が追加されていません", "please_try_again");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
on Exception catch(_){
|
||||||
|
settingGoal.value = false;
|
||||||
|
}
|
||||||
|
finally{
|
||||||
|
settingGoal.value = false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Text("finish_goal".tr)
|
child:Text("finish_goal".tr)
|
||||||
):
|
)
|
||||||
|
:
|
||||||
|
Container(
|
||||||
|
child: Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
:
|
||||||
Container()
|
Container()
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user