Exception Widget & Fixes

updare-to-3.32.sultan
Aamir Muhammad 7 months ago
parent 4d4e7e5a5b
commit e6dad37ca3

@ -15,6 +15,7 @@ import 'package:hmg_patient_app/models/Authentication/check_paitent_authenticati
import 'package:hmg_patient_app/models/Authentication/select_device_imei_res.dart'; import 'package:hmg_patient_app/models/Authentication/select_device_imei_res.dart';
import 'package:hmg_patient_app/models/InPatientServices/get_admission_info_response_model.dart'; import 'package:hmg_patient_app/models/InPatientServices/get_admission_info_response_model.dart';
import 'package:hmg_patient_app/models/InPatientServices/get_admission_request_info_response_model.dart'; import 'package:hmg_patient_app/models/InPatientServices/get_admission_request_info_response_model.dart';
import 'package:hmg_patient_app/new_ui/new_ext.dart';
import 'package:hmg_patient_app/new_ui/otp/otp_validation_bootmsheet_widget.dart'; import 'package:hmg_patient_app/new_ui/otp/otp_validation_bootmsheet_widget.dart';
import 'package:hmg_patient_app/pages/landing/landing_page.dart'; import 'package:hmg_patient_app/pages/landing/landing_page.dart';
import 'package:hmg_patient_app/pages/login/register_new.dart'; import 'package:hmg_patient_app/pages/login/register_new.dart';
@ -37,6 +38,7 @@ import 'package:hmg_patient_app/widgets/transitions/fade_page.dart';
import 'package:local_auth/local_auth.dart'; import 'package:local_auth/local_auth.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../new_ui/exception_widget/ExceptionBottomSheet.dart';
import '../../widgets/dialogs/confirm_dialog.dart'; import '../../widgets/dialogs/confirm_dialog.dart';
class SavedLogin extends StatefulWidget { class SavedLogin extends StatefulWidget {
@ -330,7 +332,14 @@ class _SavedLogin extends State<SavedLogin> {
); );
} on PlatformException catch (e) { } on PlatformException catch (e) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: 'Please enable your Touch or Face ID'); context.showBottomSheet(
child: ExceptionBottomSheet(
message: "Please enable your Touch or Face ID",
showCancel: false,
onOkPressed: () {
Navigator.of(context).pop();
}),
);
return; return;
} }
@ -369,19 +378,29 @@ class _SavedLogin extends State<SavedLogin> {
// this.patientOutSA = result['PatientOutSA']; // this.patientOutSA = result['PatientOutSA'];
// setDefault(); // setDefault();
sharedPref.setInt(LAST_LOGIN, lastLogin); sharedPref.setInt(LAST_LOGIN, lastLogin);
checkActivationCode(null, lastLogin, result['LogInTokenID']); checkActivationCode(null, lastLogin, result['LogInTokenID'], onWrongActivationCode: (String? message) {});
} else if (result['ErrorEndUserMessage'] != null) { } else if (result['ErrorEndUserMessage'] != null) {
ConfirmDialog dialog = new ConfirmDialog( GifLoaderDialogUtils.hideDialog(context);
context: context, context.showBottomSheet(
confirmMessage: result['ErrorEndUserMessage'], child: ExceptionBottomSheet(
okText: TranslationBase.of(context).confirm, message: result['ErrorEndUserMessage'],
cancelText: TranslationBase.of(context).cancel_nocaps, showCancel: true,
okFunction: () => { onOkPressed: () {
ConfirmDialog.closeAlertDialog(context), Navigator.of(context).pop();
Navigator.of(context).pushReplacement(FadePage(page: WelcomeLogin())), Navigator.of(context).pushReplacement(FadePage(page: WelcomeLogin()));
}, }),
cancelFunction: () => {}); );
dialog.showAlertDialog(context); // ConfirmDialog dialog = new ConfirmDialog(
// context: context,
// confirmMessage: result['ErrorEndUserMessage'],
// okText: TranslationBase.of(context).confirm,
// cancelText: TranslationBase.of(context).cancel_nocaps,
// okFunction: () => {
// ConfirmDialog.closeAlertDialog(context),
// Navigator.of(context).pushReplacement(FadePage(page: WelcomeLogin())),
// },
// cancelFunction: () => {});
// dialog.showAlertDialog(context);
} }
}).catchError((err) { }).catchError((err) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
@ -389,7 +408,7 @@ class _SavedLogin extends State<SavedLogin> {
}); });
} }
checkActivationCode(String? value, int loginType, String? loginToken) async { checkActivationCode(String? value, int loginType, String? loginToken, {required Function(String? message) onWrongActivationCode}) async {
AppGlobal.context = context; AppGlobal.context = context;
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
var request = authService var request = authService
@ -416,10 +435,11 @@ class _SavedLogin extends State<SavedLogin> {
{ {
//699 block run here //699 block run here
GifLoaderDialogUtils.hideDialog(context), GifLoaderDialogUtils.hideDialog(context),
Future.delayed(Duration(seconds: 2), () { onWrongActivationCode(result.errorEndUserMessage),
AppToast.showErrorToast(message: result.errorEndUserMessage); // Future.delayed(Duration(seconds: 2), () {
Navigator.pop(context); // AppToast.showErrorToast(message: result.errorEndUserMessage);
}) // Navigator.pop(context);
// })
} }
else else
{ {
@ -443,9 +463,10 @@ class _SavedLogin extends State<SavedLogin> {
{ {
// Navigator.of(context).pop(), // Navigator.of(context).pop(),
GifLoaderDialogUtils.hideDialog(context), GifLoaderDialogUtils.hideDialog(context),
Future.delayed(Duration(seconds: 1), () { onWrongActivationCode(result),
AppToast.showErrorToast(message: result, localContext: context); // Future.delayed(Duration(seconds: 1), () {
}), // AppToast.showErrorToast(message: result, localContext: context);
// }),
projectViewModel.analytics.loginRegistration.login_fail(error: result), projectViewModel.analytics.loginRegistration.login_fail(error: result),
projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result) projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result)
} }
@ -576,7 +597,7 @@ class _SavedLogin extends State<SavedLogin> {
else else
{ {
if (value['IsAuthenticated']) if (value['IsAuthenticated'])
{this.checkActivationCode(null, type, value['LogInTokenID'])} {this.checkActivationCode(null, type, value['LogInTokenID'], onWrongActivationCode: (String? message) {})}
else else
{ {
AppToast.showErrorToast(message: value['errorMessage']), AppToast.showErrorToast(message: value['errorMessage']),
@ -592,17 +613,27 @@ class _SavedLogin extends State<SavedLogin> {
.catchError((err) { .catchError((err) {
print(err); print(err);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
ConfirmDialog dialog = new ConfirmDialog( context.showBottomSheet(
context: context, child: ExceptionBottomSheet(
confirmMessage: err, message: err,
okText: TranslationBase.of(context).confirm, showCancel: true,
cancelText: TranslationBase.of(context).cancel_nocaps, onOkPressed: () {
okFunction: () => { Navigator.of(context).pop();
ConfirmDialog.closeAlertDialog(context), Navigator.of(context).pushReplacement(FadePage(page: RegisterNew()));
Navigator.of(context).push(FadePage(page: RegisterNew())), }),
}, );
cancelFunction: () => {});
dialog.showAlertDialog(context); // ConfirmDialog dialog = new ConfirmDialog(
// context: context,
// confirmMessage: err,
// okText: TranslationBase.of(context).confirm,
// cancelText: TranslationBase.of(context).cancel_nocaps,
// okFunction: () => {
// ConfirmDialog.closeAlertDialog(context),
// Navigator.of(context).push(FadePage(page: RegisterNew())),
// },
// cancelFunction: () => {});
// dialog.showAlertDialog(context);
projectViewModel.analytics.loginRegistration.login_fail(error: err.toString()); projectViewModel.analytics.loginRegistration.login_fail(error: err.toString());
}); });
} }
@ -631,28 +662,20 @@ class _SavedLogin extends State<SavedLogin> {
} }
}).catchError((r) { }).catchError((r) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: r.toString()); context.showBottomSheet(
child: ExceptionBottomSheet(
message: r,
showCancel: false,
onOkPressed: () {
Navigator.of(context).pop();
}),
);
// AppToast.showErrorToast(message: r.toString());
}); });
} }
var tempType; var tempType;
//
// startSMSService(type, String loginToken) {
// tempType = type;
// SMSOTP(
// context,
// type,
// phoneController.text,
// (value) {
// this.checkActivationCode(value, type, loginToken);
// },
// () => {
// Navigator.pop(context),
// },
// ).displayDialog(context);
// }
startSMSService(type, String loginToken) { startSMSService(type, String loginToken) {
tempType = type; tempType = type;
late SMSOTP smsOtp; // Declare the variable first late SMSOTP smsOtp; // Declare the variable first
@ -662,8 +685,17 @@ class _SavedLogin extends State<SavedLogin> {
type, type,
phoneController!.text, phoneController!.text,
(code) { (code) {
smsOtp.dispose(); // Now we can reference it checkActivationCode(code, type, loginToken, onWrongActivationCode: (String? message) {
this.checkActivationCode(code, type, loginToken); context.showBottomSheet(
child: ExceptionBottomSheet(
message: message.toString(),
onOkPressed: () {
Navigator.of(context).pop();
// Don't resume timer here, let it continue naturally when user tries again
},
),
);
});
}, },
() { () {
smsOtp.dispose(); // Now we can reference it smsOtp.dispose(); // Now we can reference it

Loading…
Cancel
Save