|
|
|
|
@ -48,6 +48,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
final DialogService _dialogService;
|
|
|
|
|
final NavigationService _navigationService;
|
|
|
|
|
final LocalAuthService _localAuthService;
|
|
|
|
|
|
|
|
|
|
AuthenticationViewModel({
|
|
|
|
|
required AppState appState,
|
|
|
|
|
required AuthenticationRepo authenticationRepo,
|
|
|
|
|
@ -79,6 +80,8 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
CalenderEnum calenderType = CalenderEnum.gregorian;
|
|
|
|
|
LoginTypeEnum loginTypeEnum = LoginTypeEnum.sms;
|
|
|
|
|
|
|
|
|
|
final ValueNotifier<bool> otpScreenNotifier = ValueNotifier<bool>(false);
|
|
|
|
|
|
|
|
|
|
//==================
|
|
|
|
|
|
|
|
|
|
String errorMsg = '';
|
|
|
|
|
@ -106,7 +109,6 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> clearDefaultInputValues() async {
|
|
|
|
|
|
|
|
|
|
nationalIdController.clear();
|
|
|
|
|
phoneNumberController.clear();
|
|
|
|
|
emailController.clear();
|
|
|
|
|
@ -394,12 +396,8 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
return isUserComingForRegister;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> checkActivationCode({
|
|
|
|
|
required String? activationCode,
|
|
|
|
|
required OTPTypeEnum otpTypeEnum,
|
|
|
|
|
required Function(String? message) onWrongActivationCode,
|
|
|
|
|
Function()? onResendActivation,
|
|
|
|
|
}) async {
|
|
|
|
|
Future<void> checkActivationCode(
|
|
|
|
|
{required String? activationCode, required OTPTypeEnum otpTypeEnum, required Function(String? message) onWrongActivationCode, Function()? onResendActivation}) async {
|
|
|
|
|
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true || _appState.getUserRegistrationPayload.patientOutSa == 1);
|
|
|
|
|
|
|
|
|
|
final request = RequestUtils.getCommonRequestWelcome(
|
|
|
|
|
@ -422,6 +420,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
countryCode: _appState.getSelectDeviceByImeiRespModelElement != null && _appState.getSelectDeviceByImeiRespModelElement!.outSa == true
|
|
|
|
|
? CountryEnum.unitedArabEmirates.countryCode
|
|
|
|
|
: selectedCountrySignup.countryCode,
|
|
|
|
|
//TODO: Error Here IN Zip Code.
|
|
|
|
|
loginType: loginTypeEnum.toInt)
|
|
|
|
|
.toJson();
|
|
|
|
|
LoaderBottomSheet.showLoader();
|
|
|
|
|
@ -469,6 +468,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
failure: failure,
|
|
|
|
|
onUnHandledFailure: (failure) async {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
otpScreenNotifier.value = true;
|
|
|
|
|
await _dialogService.showCommonBottomSheetWithoutH(message: failure.message, label: LocaleKeys.notice.tr(), onOkPressed: () {});
|
|
|
|
|
},
|
|
|
|
|
onMessageStatusFailure: (failure) async {
|
|
|
|
|
@ -595,6 +595,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> onWrongActivationCode({String? message}) async {
|
|
|
|
|
otpScreenNotifier.value = true;
|
|
|
|
|
await _dialogService.showErrorBottomSheet(message: message ?? "Something went wrong. ", onOkPressed: () {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -622,19 +623,20 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkLastLoginStatus(Function() onSuccess) async {
|
|
|
|
|
|
|
|
|
|
Future.delayed(Duration(seconds: 1), () async {
|
|
|
|
|
if(cacheService.getBool(key: CacheConst.quickLoginEnabled) == null){
|
|
|
|
|
if (cacheService.getBool(key: CacheConst.quickLoginEnabled) == null) {
|
|
|
|
|
if (_appState.getSelectDeviceByImeiRespModelElement != null &&
|
|
|
|
|
(_appState.getSelectDeviceByImeiRespModelElement!.logInType == 1 || _appState.getSelectDeviceByImeiRespModelElement!.logInType == 4)) {
|
|
|
|
|
phoneNumberController.text =
|
|
|
|
|
(_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0") ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "") : _appState.getAuthenticatedUser()!.mobileNumber)!;
|
|
|
|
|
phoneNumberController.text = (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0")
|
|
|
|
|
? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "")
|
|
|
|
|
: _appState.getAuthenticatedUser()!.mobileNumber)!;
|
|
|
|
|
nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!;
|
|
|
|
|
onSuccess();
|
|
|
|
|
} else if ((loginTypeEnum == LoginTypeEnum.sms || loginTypeEnum == LoginTypeEnum.whatsapp && _appState.getSelectDeviceByImeiRespModelElement == null) &&
|
|
|
|
|
_appState.getAuthenticatedUser() != null) {
|
|
|
|
|
phoneNumberController.text =
|
|
|
|
|
(_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0") ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "") : _appState.getAuthenticatedUser()!.mobileNumber)!;
|
|
|
|
|
phoneNumberController.text = (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0")
|
|
|
|
|
? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "")
|
|
|
|
|
: _appState.getAuthenticatedUser()!.mobileNumber)!;
|
|
|
|
|
nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!;
|
|
|
|
|
onSuccess();
|
|
|
|
|
}
|
|
|
|
|
@ -921,4 +923,6 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// === OTP Widget Logics ===//
|
|
|
|
|
}
|
|
|
|
|
|