location timeout handled in online check-in via location

dev_3.3_AmbulanceRequestCR^2
haroon amjad 2 years ago
parent eb1bddf772
commit c29e2c88f0

@ -1905,4 +1905,5 @@ const Map localizedValues = {
"locationCheckInError": {"en": "Please make sure that you're within the hospital location to perform online check-in.", "ar": "يرجى التأكد من تواجدك داخل موقع المستشفى لإجراء تسجيل الوصول عبر الإنترنت."},
"upcoming": {"en": "Upcoming", "ar": "المواعيد القادمة"},
"noUpcomingAppointment": {"en": "No upcoming appointments", "ar": "لا توجد مواعيد القادمة"},
"locationTimeoutError": {"en": "Unable to fetch your location, Please try again.", "ar": "غير قادر على جلب موقعك، يرجى المحاولة مرة أخرى."},
};

@ -36,9 +36,12 @@ class LocationUtils {
if (value) {
await Geolocator.checkPermission().then((permission) async {
if (permission == LocationPermission.always || permission == LocationPermission.whileInUse) {
Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.low, timeLimit: Duration(seconds: 10)).then((value) {
Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.best, timeLimit: Duration(seconds: 1)).then((value) {
setLocation(value);
if (callBack != null) callBack(LatLng(value.latitude, value.longitude));
}).catchError((err) {
print(err);
if (isShowConfirmDialog) showLocationTimeOutDialog(failureCallBack: failureCallBack);
});
}
@ -52,7 +55,7 @@ class LocationUtils {
if (callBack != null) callBack(LatLng(value.latitude, value.longitude));
});
} else {
if (isShowConfirmDialog) showErrorLocationDialog(false);
if (isShowConfirmDialog) showErrorLocationDialog(false, failureCallBack: failureCallBack);
}
});
} else {
@ -60,7 +63,7 @@ class LocationUtils {
getCurrentLocation(callBack: callBack);
} else {
setZeroLocation();
if (isShowConfirmDialog) showErrorLocationDialog(false);
if (isShowConfirmDialog) showErrorLocationDialog(false, failureCallBack: failureCallBack);
}
}
}
@ -141,6 +144,27 @@ class LocationUtils {
}
}
showLocationTimeOutDialog({Function() failureCallBack}) {
ConfirmDialog dialog = new ConfirmDialog(
context: context,
confirmMessage: TranslationBase.of(context).locationTimeoutError,
okText: TranslationBase.of(context).ok,
cancelText: TranslationBase.of(context).cancel_nocaps,
okFunction: () {
ConfirmDialog.closeAlertDialog(context);
Navigator.of(context).canPop();
if (failureCallBack != null) {
failureCallBack();
}
},
cancelFunction: () {
if (failureCallBack != null) {
failureCallBack();
}
});
return dialog.showAlertDialog(context);
}
showErrorLocationDialog(bool isPermissionError, {Function() failureCallBack}) {
ConfirmDialog dialog = new ConfirmDialog(
context: context,

@ -2914,6 +2914,7 @@ class TranslationBase {
String get locationCheckInError => localizedValues["locationCheckInError"][locale.languageCode];
String get upcoming => localizedValues["upcoming"][locale.languageCode];
String get noUpcomingAppointment => localizedValues["noUpcomingAppointment"][locale.languageCode];
String get locationTimeoutError => localizedValues["locationTimeoutError"][locale.languageCode];
}

Loading…
Cancel
Save