|  |  |  | @ -2,6 +2,7 @@ import 'package:flutter/material.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/core/app_state.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/core/enums.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/core/utils/request_utils.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/core/utils/utils.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/features/authentication/authentication_repo.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/features/authentication/models/request_models/check_patient_authentication_request_model.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/services/dialog_service.dart'; | 
		
	
	
		
			
				
					|  |  |  | @ -23,9 +24,15 @@ class AuthenticationViewModel extends ChangeNotifier { | 
		
	
		
			
				|  |  |  |  |   final TextEditingController nationalIdController = TextEditingController(); | 
		
	
		
			
				|  |  |  |  |   final TextEditingController phoneNumberController = TextEditingController(); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void login() { | 
		
	
		
			
				|  |  |  |  |     if (ValidationUtils.isValidatePhoneAndId(nationalId: nationalIdController.text, phoneNumber: phoneNumberController.text)) { | 
		
	
		
			
				|  |  |  |  |     } else { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<void> selectDeviceImei({Function(dynamic)? onSuccess, Function(String)? onError}) async { | 
		
	
		
			
				|  |  |  |  |     String firebaseToken = | 
		
	
		
			
				|  |  |  |  |         "dOGRRszQQMGe_9wA5Hx3kO:APA91bFV5IcIJXvcCXXk0tc2ddtZgWwCPq7sGSuPr-YW7iiJpQZKgFGN9GAzCVOWL8MfheaP1slE8MdxB7lczdPBGdONQ7WbMmhgHcsUCUktq-hsapGXXqc"; | 
		
	
		
			
				|  |  |  |  |     String firebaseToken = "dOGRRszQQMGe_9wA5Hx3kO:APA91bFV5IcIJXvcCXXk0tc2ddtZgWwCPq7sGSuPr-YW7iiJpQZKgFGN9GAzCVOWL8MfheaP1slE8MdxB7lczdPBGdONQ7WbMmhgHcsUCUktq-hsapGXXqc"; | 
		
	
		
			
				|  |  |  |  |     final result = await authenticationRepo.selectDeviceByImei(firebaseToken: firebaseToken); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     result.fold( | 
		
	
	
		
			
				
					|  |  |  | @ -40,96 +47,96 @@ class AuthenticationViewModel extends ChangeNotifier { | 
		
	
		
			
				|  |  |  |  |     ); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   // Future<void> checkUserAuthentication({Function(dynamic)? onSuccess, Function(String)? onError}) async { | 
		
	
		
			
				|  |  |  |  |   //   CheckPatientAuthenticationReq checkPatientAuthenticationReq = RequestUtils.getCommonRequestWelcome( | 
		
	
		
			
				|  |  |  |  |   //     phoneNumber: '0567184134', | 
		
	
		
			
				|  |  |  |  |   //     otpTypeEnum: OTPTypeEnum.sms, | 
		
	
		
			
				|  |  |  |  |   //     deviceToken: 'dummyDeviceToken123', | 
		
	
		
			
				|  |  |  |  |   //     patientOutSA: true, | 
		
	
		
			
				|  |  |  |  |   //     loginTokenID: 'dummyLoginToken456', | 
		
	
		
			
				|  |  |  |  |   //     registeredData: null, | 
		
	
		
			
				|  |  |  |  |   //     patientId: 12345, | 
		
	
		
			
				|  |  |  |  |   //     nationIdText: '1234567890', | 
		
	
		
			
				|  |  |  |  |   //     countryCode: 'SA', | 
		
	
		
			
				|  |  |  |  |   //   ); | 
		
	
		
			
				|  |  |  |  |   // | 
		
	
		
			
				|  |  |  |  |   //   final result = await authenticationRepo.checkPatientAuthentication(checkPatientAuthenticationReq: checkPatientAuthenticationReq); | 
		
	
		
			
				|  |  |  |  |   //   result.fold( | 
		
	
		
			
				|  |  |  |  |   //     (failure) async => await errorHandlerService.handleError(failure: failure), | 
		
	
		
			
				|  |  |  |  |   //     (apiResponse) { | 
		
	
		
			
				|  |  |  |  |   //       if (apiResponse.data['isSMSSent']) { | 
		
	
		
			
				|  |  |  |  |   //         // TODO:  set this in AppState | 
		
	
		
			
				|  |  |  |  |   //         // sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']); | 
		
	
		
			
				|  |  |  |  |   //         //    loginTokenID = value['LogInTokenID'], | 
		
	
		
			
				|  |  |  |  |   //         // sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, request), | 
		
	
		
			
				|  |  |  |  |   //         sendActivationCode(type); | 
		
	
		
			
				|  |  |  |  |   //       } else { | 
		
	
		
			
				|  |  |  |  |   //         if (apiResponse.data['IsAuthenticated']) { | 
		
	
		
			
				|  |  |  |  |   //           checkActivationCode(onWrongActivationCode: (String? message) {}); | 
		
	
		
			
				|  |  |  |  |   //         } | 
		
	
		
			
				|  |  |  |  |   //       } | 
		
	
		
			
				|  |  |  |  |   //     }, | 
		
	
		
			
				|  |  |  |  |   //   ); | 
		
	
		
			
				|  |  |  |  |   // } | 
		
	
		
			
				|  |  |  |  | // Future<void> checkUserAuthentication({Function(dynamic)? onSuccess, Function(String)? onError}) async { | 
		
	
		
			
				|  |  |  |  | //   CheckPatientAuthenticationReq checkPatientAuthenticationReq = RequestUtils.getCommonRequestWelcome( | 
		
	
		
			
				|  |  |  |  | //     phoneNumber: '0567184134', | 
		
	
		
			
				|  |  |  |  | //     otpTypeEnum: OTPTypeEnum.sms, | 
		
	
		
			
				|  |  |  |  | //     deviceToken: 'dummyDeviceToken123', | 
		
	
		
			
				|  |  |  |  | //     patientOutSA: true, | 
		
	
		
			
				|  |  |  |  | //     loginTokenID: 'dummyLoginToken456', | 
		
	
		
			
				|  |  |  |  | //     registeredData: null, | 
		
	
		
			
				|  |  |  |  | //     patientId: 12345, | 
		
	
		
			
				|  |  |  |  | //     nationIdText: '1234567890', | 
		
	
		
			
				|  |  |  |  | //     countryCode: 'SA', | 
		
	
		
			
				|  |  |  |  | //   ); | 
		
	
		
			
				|  |  |  |  | // | 
		
	
		
			
				|  |  |  |  | //   final result = await authenticationRepo.checkPatientAuthentication(checkPatientAuthenticationReq: checkPatientAuthenticationReq); | 
		
	
		
			
				|  |  |  |  | //   result.fold( | 
		
	
		
			
				|  |  |  |  | //     (failure) async => await errorHandlerService.handleError(failure: failure), | 
		
	
		
			
				|  |  |  |  | //     (apiResponse) { | 
		
	
		
			
				|  |  |  |  | //       if (apiResponse.data['isSMSSent']) { | 
		
	
		
			
				|  |  |  |  | //         // TODO:  set this in AppState | 
		
	
		
			
				|  |  |  |  | //         // sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']); | 
		
	
		
			
				|  |  |  |  | //         //    loginTokenID = value['LogInTokenID'], | 
		
	
		
			
				|  |  |  |  | //         // sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, request), | 
		
	
		
			
				|  |  |  |  | //         sendActivationCode(type); | 
		
	
		
			
				|  |  |  |  | //       } else { | 
		
	
		
			
				|  |  |  |  | //         if (apiResponse.data['IsAuthenticated']) { | 
		
	
		
			
				|  |  |  |  | //           checkActivationCode(onWrongActivationCode: (String? message) {}); | 
		
	
		
			
				|  |  |  |  | //         } | 
		
	
		
			
				|  |  |  |  | //       } | 
		
	
		
			
				|  |  |  |  | //     }, | 
		
	
		
			
				|  |  |  |  | //   ); | 
		
	
		
			
				|  |  |  |  | // } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   // Future<void> sendActivationCode({required OTPTypeEnum otpTypeEnum}) async { | 
		
	
		
			
				|  |  |  |  |   //   var request = RequestUtils.getCommonRequestAuthProvider( | 
		
	
		
			
				|  |  |  |  |   //     otpTypeEnum: otpTypeEnum, | 
		
	
		
			
				|  |  |  |  |   //     registeredData: null, | 
		
	
		
			
				|  |  |  |  |   //     deviceToken: "dummyLoginToken456", | 
		
	
		
			
				|  |  |  |  |   //     mobileNumber: "0567184134", | 
		
	
		
			
				|  |  |  |  |   //     zipCode: "SA", | 
		
	
		
			
				|  |  |  |  |   //     patientOutSA: true, | 
		
	
		
			
				|  |  |  |  |   //     loginTokenID: "dummyLoginToken456", | 
		
	
		
			
				|  |  |  |  |   //     selectedOption: selectedOption, | 
		
	
		
			
				|  |  |  |  |   //     patientId: 12345, | 
		
	
		
			
				|  |  |  |  |   //   ); | 
		
	
		
			
				|  |  |  |  |   // | 
		
	
		
			
				|  |  |  |  |   //   request.sMSSignature = await SMSOTP.getSignature(); | 
		
	
		
			
				|  |  |  |  |   //   selectedOption = type; | 
		
	
		
			
				|  |  |  |  |   //   // GifLoaderDialogUtils.showMyDialog(context); | 
		
	
		
			
				|  |  |  |  |   //   if (healthId != null || isDubai) { | 
		
	
		
			
				|  |  |  |  |   //     if (!isDubai) { | 
		
	
		
			
				|  |  |  |  |   //       request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob)); | 
		
	
		
			
				|  |  |  |  |   //     } | 
		
	
		
			
				|  |  |  |  |   //     request.healthId = healthId; | 
		
	
		
			
				|  |  |  |  |   //     request.isHijri = isHijri; | 
		
	
		
			
				|  |  |  |  |   //     await this.apiClient.sendActivationCodeRegister(request).then((result) { | 
		
	
		
			
				|  |  |  |  |   //       // GifLoaderDialogUtils.hideDialog(context); | 
		
	
		
			
				|  |  |  |  |   //       if (result != null && result['isSMSSent'] == true) { | 
		
	
		
			
				|  |  |  |  |   //         this.startSMSService(type); | 
		
	
		
			
				|  |  |  |  |   //       } | 
		
	
		
			
				|  |  |  |  |   //     }).catchError((r) { | 
		
	
		
			
				|  |  |  |  |   //       GifLoaderDialogUtils.hideDialog(context); | 
		
	
		
			
				|  |  |  |  |   //       context.showBottomSheet( | 
		
	
		
			
				|  |  |  |  |   //           child: ExceptionBottomSheet( | 
		
	
		
			
				|  |  |  |  |   //         message: r.toString(), | 
		
	
		
			
				|  |  |  |  |   //         onOkPressed: () { | 
		
	
		
			
				|  |  |  |  |   //           Navigator.of(context).pop(); | 
		
	
		
			
				|  |  |  |  |   //         }, | 
		
	
		
			
				|  |  |  |  |   //       )); | 
		
	
		
			
				|  |  |  |  |   //       // AppToast.showErrorToast(message: r); | 
		
	
		
			
				|  |  |  |  |   //     }); | 
		
	
		
			
				|  |  |  |  |   //   } else { | 
		
	
		
			
				|  |  |  |  |   //     request.dob = ""; | 
		
	
		
			
				|  |  |  |  |   //     request.healthId = ""; | 
		
	
		
			
				|  |  |  |  |   //     request.isHijri = 0; | 
		
	
		
			
				|  |  |  |  |   //     await this.authService.sendActivationCode(request).then((result) { | 
		
	
		
			
				|  |  |  |  |   //       GifLoaderDialogUtils.hideDialog(context); | 
		
	
		
			
				|  |  |  |  |   //       if (result != null && result['isSMSSent'] == true) { | 
		
	
		
			
				|  |  |  |  |   //         this.startSMSService(type); | 
		
	
		
			
				|  |  |  |  |   //       } | 
		
	
		
			
				|  |  |  |  |   //     }).catchError((r) { | 
		
	
		
			
				|  |  |  |  |   //       GifLoaderDialogUtils.hideDialog(context); | 
		
	
		
			
				|  |  |  |  |   //       context.showBottomSheet( | 
		
	
		
			
				|  |  |  |  |   //           child: ExceptionBottomSheet( | 
		
	
		
			
				|  |  |  |  |   //         message: r.toString(), | 
		
	
		
			
				|  |  |  |  |   //         onOkPressed: () { | 
		
	
		
			
				|  |  |  |  |   //           Navigator.of(context).pop(); | 
		
	
		
			
				|  |  |  |  |   //         }, | 
		
	
		
			
				|  |  |  |  |   //       )); | 
		
	
		
			
				|  |  |  |  |   //       // AppToast.showErrorToast(message: r.toString()); | 
		
	
		
			
				|  |  |  |  |   //     }); | 
		
	
		
			
				|  |  |  |  |   //   } | 
		
	
		
			
				|  |  |  |  |   // } | 
		
	
		
			
				|  |  |  |  | // Future<void> sendActivationCode({required OTPTypeEnum otpTypeEnum}) async { | 
		
	
		
			
				|  |  |  |  | //   var request = RequestUtils.getCommonRequestAuthProvider( | 
		
	
		
			
				|  |  |  |  | //     otpTypeEnum: otpTypeEnum, | 
		
	
		
			
				|  |  |  |  | //     registeredData: null, | 
		
	
		
			
				|  |  |  |  | //     deviceToken: "dummyLoginToken456", | 
		
	
		
			
				|  |  |  |  | //     mobileNumber: "0567184134", | 
		
	
		
			
				|  |  |  |  | //     zipCode: "SA", | 
		
	
		
			
				|  |  |  |  | //     patientOutSA: true, | 
		
	
		
			
				|  |  |  |  | //     loginTokenID: "dummyLoginToken456", | 
		
	
		
			
				|  |  |  |  | //     selectedOption: selectedOption, | 
		
	
		
			
				|  |  |  |  | //     patientId: 12345, | 
		
	
		
			
				|  |  |  |  | //   ); | 
		
	
		
			
				|  |  |  |  | // | 
		
	
		
			
				|  |  |  |  | //   request.sMSSignature = await SMSOTP.getSignature(); | 
		
	
		
			
				|  |  |  |  | //   selectedOption = type; | 
		
	
		
			
				|  |  |  |  | //   // GifLoaderDialogUtils.showMyDialog(context); | 
		
	
		
			
				|  |  |  |  | //   if (healthId != null || isDubai) { | 
		
	
		
			
				|  |  |  |  | //     if (!isDubai) { | 
		
	
		
			
				|  |  |  |  | //       request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob)); | 
		
	
		
			
				|  |  |  |  | //     } | 
		
	
		
			
				|  |  |  |  | //     request.healthId = healthId; | 
		
	
		
			
				|  |  |  |  | //     request.isHijri = isHijri; | 
		
	
		
			
				|  |  |  |  | //     await this.apiClient.sendActivationCodeRegister(request).then((result) { | 
		
	
		
			
				|  |  |  |  | //       // GifLoaderDialogUtils.hideDialog(context); | 
		
	
		
			
				|  |  |  |  | //       if (result != null && result['isSMSSent'] == true) { | 
		
	
		
			
				|  |  |  |  | //         this.startSMSService(type); | 
		
	
		
			
				|  |  |  |  | //       } | 
		
	
		
			
				|  |  |  |  | //     }).catchError((r) { | 
		
	
		
			
				|  |  |  |  | //       GifLoaderDialogUtils.hideDialog(context); | 
		
	
		
			
				|  |  |  |  | //       context.showBottomSheet( | 
		
	
		
			
				|  |  |  |  | //           child: ExceptionBottomSheet( | 
		
	
		
			
				|  |  |  |  | //         message: r.toString(), | 
		
	
		
			
				|  |  |  |  | //         onOkPressed: () { | 
		
	
		
			
				|  |  |  |  | //           Navigator.of(context).pop(); | 
		
	
		
			
				|  |  |  |  | //         }, | 
		
	
		
			
				|  |  |  |  | //       )); | 
		
	
		
			
				|  |  |  |  | //       // AppToast.showErrorToast(message: r); | 
		
	
		
			
				|  |  |  |  | //     }); | 
		
	
		
			
				|  |  |  |  | //   } else { | 
		
	
		
			
				|  |  |  |  | //     request.dob = ""; | 
		
	
		
			
				|  |  |  |  | //     request.healthId = ""; | 
		
	
		
			
				|  |  |  |  | //     request.isHijri = 0; | 
		
	
		
			
				|  |  |  |  | //     await this.authService.sendActivationCode(request).then((result) { | 
		
	
		
			
				|  |  |  |  | //       GifLoaderDialogUtils.hideDialog(context); | 
		
	
		
			
				|  |  |  |  | //       if (result != null && result['isSMSSent'] == true) { | 
		
	
		
			
				|  |  |  |  | //         this.startSMSService(type); | 
		
	
		
			
				|  |  |  |  | //       } | 
		
	
		
			
				|  |  |  |  | //     }).catchError((r) { | 
		
	
		
			
				|  |  |  |  | //       GifLoaderDialogUtils.hideDialog(context); | 
		
	
		
			
				|  |  |  |  | //       context.showBottomSheet( | 
		
	
		
			
				|  |  |  |  | //           child: ExceptionBottomSheet( | 
		
	
		
			
				|  |  |  |  | //         message: r.toString(), | 
		
	
		
			
				|  |  |  |  | //         onOkPressed: () { | 
		
	
		
			
				|  |  |  |  | //           Navigator.of(context).pop(); | 
		
	
		
			
				|  |  |  |  | //         }, | 
		
	
		
			
				|  |  |  |  | //       )); | 
		
	
		
			
				|  |  |  |  | //       // AppToast.showErrorToast(message: r.toString()); | 
		
	
		
			
				|  |  |  |  | //     }); | 
		
	
		
			
				|  |  |  |  | //   } | 
		
	
		
			
				|  |  |  |  | // } | 
		
	
		
			
				|  |  |  |  | } | 
		
	
	
		
			
				
					|  |  |  | 
 |