From 496c6ce32e399923678ad02065ed93fdfd4053b1 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Thu, 21 Oct 2021 15:55:37 +0300 Subject: [PATCH] registration done --- lib/config/localized_values.dart | 7 +- .../check_activation_code_request.dart | 53 +- ...heck_activation_code_request_register.dart | 120 ++++ .../Authentication/register_user_requet.dart | 27 +- .../send_activation_request.dart | 14 +- lib/pages/login/confirm-login.dart | 182 +++-- lib/pages/login/login-type.dart | 4 +- lib/pages/login/login.dart | 7 +- lib/pages/login/register-info.dart | 648 ++++++++++++------ lib/pages/login/register.dart | 365 +++++++--- lib/pages/login/register_new.dart | 203 ++++++ .../authentication/auth_provider.dart | 70 +- lib/uitl/translations_delegate_base.dart | 2 + 13 files changed, 1300 insertions(+), 402 deletions(-) create mode 100644 lib/models/Authentication/check_activation_code_request_register.dart create mode 100644 lib/pages/login/register_new.dart diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index c7a60f96..8c86993f 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1512,14 +1512,15 @@ const Map localizedValues = { "modesBelow": {"en": "Please select the modes below:", "ar": ":الرجاء تحديد الأوضاع أدناه"}, "prefferedMode": {"en": "Please select the preferred mode below:", "ar": ":الرجاء تحديد الوضع المفضل أدناه"}, "permissionsBellow": {"en": "Please allow the permissions below:", "ar": ":الرجاء السماح الأذونات أدناه"}, - "appointmentReminder": { "en": "Would you like to set a reminder for this appointment in your calendar?", "ar": "هل ترغب في اضافة تذكير لهذا الموعد في التقويم؟" }, - "cancelAppointment": { "en": "Cancel Appt.", "ar": "الغاء الموعد" }, + "appointmentReminder": {"en": "Would you like to set a reminder for this appointment in your calendar?", "ar": "هل ترغب في اضافة تذكير لهذا الموعد في التقويم؟"}, + "cancelAppointment": {"en": "Cancel Appt.", "ar": "الغاء الموعد"}, "updateInsurCards": {"en": "Update Insurance Cards", "ar": "تحديث بطاقات التأمين"}, "patientAge": {"en": "y", "ar": "سنة"}, - "searchCriteria": { "en": "Select Search Criteria", "ar": "حدد معايير البحث" }, + "searchCriteria": {"en": "Select Search Criteria", "ar": "حدد معايير البحث"}, "RequesterInfo": {"en": "Requester Info", "ar": "معلومات مقدم الطلب"}, "PatientInfo": {"en": "Patient Info", "ar": "معلومات المريض"}, "OtherInfo": {"en": "Other Info", "ar": "معلومات اخرى"}, "inPrgress": {"en": "In Progress", "ar": "في تقدم"}, "locked": {"en": "Locked", "ar": "مقفل"}, + "personalInfo": {"en": "Personal Information", "ar": "معلومات شخصية"}, }; diff --git a/lib/models/Authentication/check_activation_code_request.dart b/lib/models/Authentication/check_activation_code_request.dart index af139ba5..f6509f3b 100644 --- a/lib/models/Authentication/check_activation_code_request.dart +++ b/lib/models/Authentication/check_activation_code_request.dart @@ -23,31 +23,33 @@ class CheckActivationCodeReq { bool isDentalAllowedBackend; int deviceTypeID; bool forRegisteration; - CheckActivationCodeReq( - {this.patientMobileNumber, - this.mobileNo, - this.deviceToken, - this.projectOutSA, - this.loginType, - this.zipCode, - this.isRegister, - this.logInTokenID, - this.searchType, - this.patientID, - this.nationalID, - this.patientIdentificationID, - this.activationCode, - this.isSilentLogin, - this.versionID, - this.channel, - this.languageID, - this.iPAdress, - this.generalid, - this.patientOutSA, - this.sessionID, - this.isDentalAllowedBackend, - this.deviceTypeID, - this.forRegisteration}); + + CheckActivationCodeReq({ + this.patientMobileNumber, + this.mobileNo, + this.deviceToken, + this.projectOutSA, + this.loginType, + this.zipCode, + this.isRegister, + this.logInTokenID, + this.searchType, + this.patientID, + this.nationalID, + this.patientIdentificationID, + this.activationCode, + this.isSilentLogin, + this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.forRegisteration, + }); CheckActivationCodeReq.fromJson(Map json) { patientMobileNumber = json['PatientMobileNumber']; @@ -102,6 +104,7 @@ class CheckActivationCodeReq { data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; data['DeviceTypeID'] = this.deviceTypeID; data['ForRegisteration'] = this.forRegisteration; + return data; } } diff --git a/lib/models/Authentication/check_activation_code_request_register.dart b/lib/models/Authentication/check_activation_code_request_register.dart new file mode 100644 index 00000000..c727c647 --- /dev/null +++ b/lib/models/Authentication/check_activation_code_request_register.dart @@ -0,0 +1,120 @@ +class CheckActivationCodeRegisterReq { + int patientMobileNumber; + String mobileNo; + String deviceToken; + bool projectOutSA; + int loginType; + String zipCode; + bool isRegister; + String logInTokenID; + int searchType; + int patientID; + String nationalID; + String patientIdentificationID; + String activationCode; + bool isSilentLogin; + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int patientOutSA; + Null sessionID; + bool isDentalAllowedBackend; + int deviceTypeID; + bool forRegisteration; + String dob; + int isHijri; + String healthId; + CheckActivationCodeRegisterReq({ + this.patientMobileNumber, + this.mobileNo, + this.deviceToken, + this.projectOutSA, + this.loginType, + this.zipCode, + this.isRegister, + this.logInTokenID, + this.searchType, + this.patientID, + this.nationalID, + this.patientIdentificationID, + this.activationCode, + this.isSilentLogin, + this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.forRegisteration, + this.dob, + this.isHijri, + this.healthId, + }); + + CheckActivationCodeRegisterReq.fromJson(Map json) { + patientMobileNumber = json['PatientMobileNumber']; + mobileNo = json['MobileNo']; + deviceToken = json['DeviceToken']; + projectOutSA = json['ProjectOutSA']; + loginType = json['LoginType']; + zipCode = json['ZipCode']; + isRegister = json['isRegister']; + logInTokenID = json['LogInTokenID']; + searchType = json['SearchType']; + patientID = json['PatientID']; + nationalID = json['NationalID']; + patientIdentificationID = json['PatientIdentificationID']; + activationCode = json['activationCode']; + isSilentLogin = json['IsSilentLogin']; + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + forRegisteration = json['ForRegisteration']; + dob = json['DOB']; + isHijri = json['IsHijri']; + healthId = json['HealthId']; + } + + Map toJson() { + final Map data = new Map(); + data['PatientMobileNumber'] = this.patientMobileNumber; + data['MobileNo'] = this.mobileNo; + data['DeviceToken'] = this.deviceToken; + data['ProjectOutSA'] = this.projectOutSA; + data['LoginType'] = this.loginType; + data['ZipCode'] = this.zipCode; + data['isRegister'] = this.isRegister; + data['LogInTokenID'] = this.logInTokenID; + data['SearchType'] = this.searchType; + data['PatientID'] = this.patientID; + data['NationalID'] = this.nationalID; + data['PatientIdentificationID'] = this.patientIdentificationID; + data['activationCode'] = this.activationCode; + data['IsSilentLogin'] = this.isSilentLogin; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['generalid'] = this.generalid; + data['PatientOutSA'] = this.patientOutSA; + data['SessionID'] = this.sessionID; + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; + data['DeviceTypeID'] = this.deviceTypeID; + data['ForRegisteration'] = this.forRegisteration; + data['DOB'] = dob; + data['IsHijri'] = isHijri; + data['HealthId'] = healthId; + return data; + } +} diff --git a/lib/models/Authentication/register_user_requet.dart b/lib/models/Authentication/register_user_requet.dart index 12e59d0a..63cb9e8a 100644 --- a/lib/models/Authentication/register_user_requet.dart +++ b/lib/models/Authentication/register_user_requet.dart @@ -1,7 +1,7 @@ class RegisterUserRequest { Patientobject patientobject; String patientIdentificationID; - int patientMobileNumber; + dynamic patientMobileNumber; String logInTokenID; double versionID; int channel; @@ -12,7 +12,10 @@ class RegisterUserRequest { Null sessionID; bool isDentalAllowedBackend; int deviceTypeID; - + String dob; + int isHijri; + String healthId; + String zipCode; RegisterUserRequest( {this.patientobject, this.patientIdentificationID, @@ -26,12 +29,14 @@ class RegisterUserRequest { this.patientOutSA, this.sessionID, this.isDentalAllowedBackend, - this.deviceTypeID}); + this.deviceTypeID, + this.dob, + this.isHijri, + this.healthId, + this.zipCode}); RegisterUserRequest.fromJson(Map json) { - patientobject = json['Patientobject'] != null - ? new Patientobject.fromJson(json['Patientobject']) - : null; + patientobject = json['Patientobject'] != null ? new Patientobject.fromJson(json['Patientobject']) : null; patientIdentificationID = json['PatientIdentificationID']; patientMobileNumber = json['PatientMobileNumber']; logInTokenID = json['LogInTokenID']; @@ -44,6 +49,10 @@ class RegisterUserRequest { sessionID = json['SessionID']; isDentalAllowedBackend = json['isDentalAllowedBackend']; deviceTypeID = json['DeviceTypeID']; + dob = json['DOB']; + isHijri = json['IsHijri']; + healthId = json['HealthId']; + zipCode = json['ZipCode']; } Map toJson() { @@ -63,6 +72,10 @@ class RegisterUserRequest { data['SessionID'] = this.sessionID; data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; data['DeviceTypeID'] = this.deviceTypeID; + data['DOB'] = this.dob; + data['IsHijri'] = this.isHijri; + data['HealthId'] = this.healthId; + data['ZipCode'] = this.zipCode; return data; } } @@ -71,7 +84,7 @@ class Patientobject { bool tempValue; int patientIdentificationType; String patientIdentificationNo; - int mobileNumber; + dynamic mobileNumber; int patientOutSA; String firstName; String middleName; diff --git a/lib/models/Authentication/send_activation_request.dart b/lib/models/Authentication/send_activation_request.dart index f9b386c6..e9512102 100644 --- a/lib/models/Authentication/send_activation_request.dart +++ b/lib/models/Authentication/send_activation_request.dart @@ -22,6 +22,9 @@ class SendActivationRequest { bool isDentalAllowedBackend; int deviceTypeID; String sMSSignature; + String dob; + int isHijri; + String healthId; SendActivationRequest( {this.patientMobileNumber, this.mobileNo, @@ -45,7 +48,10 @@ class SendActivationRequest { this.sessionID, this.isDentalAllowedBackend, this.deviceTypeID, - this.sMSSignature}); + this.sMSSignature, + this.dob, + this.isHijri, + this.healthId}); SendActivationRequest.fromJson(Map json) { patientMobileNumber = json['PatientMobileNumber']; @@ -71,6 +77,9 @@ class SendActivationRequest { isDentalAllowedBackend = json['isDentalAllowedBackend']; deviceTypeID = json['DeviceTypeID']; sMSSignature = json['SMSSignature']; + dob = json['DOB']; + isHijri = json['IsHijri']; + healthId = json['HealthId']; } Map toJson() { @@ -98,6 +107,9 @@ class SendActivationRequest { data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; data['DeviceTypeID'] = this.deviceTypeID; data['SMSSignature'] = sMSSignature; + data['DOB'] = dob; + data['IsHijri'] = isHijri; + data['HealthId'] = healthId; return data; } } diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index 58453550..55447b83 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -35,8 +35,12 @@ import 'package:local_auth/auth_strings.dart'; import 'package:local_auth/local_auth.dart'; import 'package:provider/provider.dart'; import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/pages/login/register_new.dart'; class ConfirmLogin extends StatefulWidget { + final Function changePageViewIndex; + const ConfirmLogin({Key key, this.changePageViewIndex}) : super(key: key); @override _ConfirmLogin createState() => _ConfirmLogin(); } @@ -83,6 +87,10 @@ class _ConfirmLogin extends State { ToDoCountProviderModel toDoProvider; + var dob; + int isHijri; + var healthId; + @override void initState() { _getAvailableBiometrics(); @@ -363,15 +371,30 @@ class _ConfirmLogin extends State { var request = this.getCommonRequest(type: type); request.sMSSignature = await SMSOTP.getSignature(); GifLoaderDialogUtils.showMyDialog(context); - - await this.authService.sendActivationCode(request).then((result) { - GifLoaderDialogUtils.hideDialog(context); - if (result != null && result['isSMSSent'] == true) { - this.startSMSService(type); - } - }).catchError((r) { - GifLoaderDialogUtils.hideDialog(context); - }); + if (healthId != null) { + // final DateFormat dateFormat = DateFormat('MM/dd/yyyy'); + // final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); + request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob)); + request.healthId = healthId; + request.isHijri = isHijri; + await this.authService.sendActivationCodeRegister(request).then((result) { + GifLoaderDialogUtils.hideDialog(context); + if (result != null && result['isSMSSent'] == true) { + this.startSMSService(type); + } + }).catchError((r) { + GifLoaderDialogUtils.hideDialog(context); + }); + } else { + await this.authService.sendActivationCode(request).then((result) { + GifLoaderDialogUtils.hideDialog(context); + if (result != null && result['isSMSSent'] == true) { + this.startSMSService(type); + } + }).catchError((r) { + GifLoaderDialogUtils.hideDialog(context); + }); + } } var tempType; @@ -472,6 +495,15 @@ class _ConfirmLogin extends State { this.loginTokenID = await sharedPref.getString(LOGIN_TOKEN_ID); this.loginType = this.registerd_data.searchType; } + var nhic = await sharedPref.getObject(NHIC_DATA); + if (nhic != null) { + final DateFormat dateFormat = DateFormat('MM/dd/yyyy'); + final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); + dob = nhic['IsHijri'] ? nhic['DateOfBirth'] : dateFormat2.format(dateFormat.parse(nhic['DateOfBirth'])); + + isHijri = nhic['IsHijri'] ? 1 : 0; + healthId = nhic['HealthId']; + } this.deviceToken = await sharedPref.getString(PUSH_TOKEN); this.lastLogin = await sharedPref.getInt(LAST_LOGIN) != null ? await sharedPref.getInt(LAST_LOGIN) @@ -515,55 +547,89 @@ class _ConfirmLogin extends State { // Navigator.pop(context); GifLoaderDialogUtils.showMyDialog(context); var request = this.getCommonRequest().toJson(); - dynamic res; - - authService - .checkActivationCode(request, value) - .then((result) => { - res = result, - if (result is Map) - { - result = CheckActivationCode.fromJson(result), - if (this.registerd_data != null && this.registerd_data.isRegister == true) - { - Navigator.of(context).pushNamed( - REGISTER_INFO, - ) - } - else - { - sharedPref.remove(FAMILY_FILE), - result.list.isFamily = false, - userData = result.list, - sharedPref.setString(BLOOD_TYPE, result.patientBloodType), - authenticatedUserObject.user = result.list, - projectViewModel.setPrivilege(privilegeList: res), - sharedPref.setObject(MAIN_USER, result.list), - sharedPref.setObject(USER_PROFILE, result.list), - loginTokenID = result.logInTokenID, - sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), - sharedPref.setString(TOKEN, result.authenticationTokenID), - checkIfUserAgreedBefore(result), - } - } - else - { - // Navigator.of(context).pop(), - GifLoaderDialogUtils.hideDialog(context), - Future.delayed(Duration(seconds: 1), () { - AppToast.showErrorToast(message: result); - }), - } - }) - .catchError((err) { - print(err); - GifLoaderDialogUtils.hideDialog(context); - Future.delayed(Duration(seconds: 1), () { - AppToast.showErrorToast(message: err); - startSMSService(tempType); + if (healthId != null) { + request['DOB'] = dob; + request['HealthId'] = healthId; + request['IsHijri'] = isHijri; + + authService + .checkActivationCodeRegister(request, value) + .then((result) => { + res = result, + if (result is Map) + { + result = CheckActivationCode.fromJson(result), + if (this.registerd_data != null && this.registerd_data.isRegister == true) + { + widget.changePageViewIndex(1), + Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), + } + } + else + { + // Navigator.of(context).pop(), + GifLoaderDialogUtils.hideDialog(context), + Future.delayed(Duration(seconds: 1), () { + AppToast.showErrorToast(message: result); + }), + } + }) + .catchError((err) { + print(err); + GifLoaderDialogUtils.hideDialog(context); + Future.delayed(Duration(seconds: 1), () { + AppToast.showErrorToast(message: err); + startSMSService(tempType); + }); }); - }); + } else { + authService + .checkActivationCode(request, value) + .then((result) => { + res = result, + if (result is Map) + { + result = CheckActivationCode.fromJson(result), + if (this.registerd_data != null && this.registerd_data.isRegister == true) + { + widget.changePageViewIndex(1), + Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), + } + else + { + sharedPref.remove(FAMILY_FILE), + result.list.isFamily = false, + userData = result.list, + sharedPref.setString(BLOOD_TYPE, result.patientBloodType), + authenticatedUserObject.user = result.list, + projectViewModel.setPrivilege(privilegeList: res), + sharedPref.setObject(MAIN_USER, result.list), + sharedPref.setObject(USER_PROFILE, result.list), + loginTokenID = result.logInTokenID, + sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), + sharedPref.setString(TOKEN, result.authenticationTokenID), + checkIfUserAgreedBefore(result), + } + } + else + { + // Navigator.of(context).pop(), + GifLoaderDialogUtils.hideDialog(context), + Future.delayed(Duration(seconds: 1), () { + AppToast.showErrorToast(message: result); + }), + } + }) + .catchError((err) { + print(err); + GifLoaderDialogUtils.hideDialog(context); + Future.delayed(Duration(seconds: 1), () { + AppToast.showErrorToast(message: err); + startSMSService(tempType); + }); + }); + } } checkIfUserAgreedBefore(CheckActivationCode result) { @@ -602,10 +668,6 @@ class _ConfirmLogin extends State { getToDoCount(); - // pharmacyModuleViewModel.generatePharmacyToken().then((value) async { - // if (pharmacyModuleViewModel.error.isNotEmpty) await pharmacyModuleViewModel.createUser(); - // }); - appointmentRateViewModel .getIsLastAppointmentRatedList() .then((value) => { diff --git a/lib/pages/login/login-type.dart b/lib/pages/login/login-type.dart index e2e08654..b77d34f3 100644 --- a/lib/pages/login/login-type.dart +++ b/lib/pages/login/login-type.dart @@ -1,7 +1,7 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/pages/login/forgot-password.dart'; import 'package:diplomaticquarterapp/pages/login/login.dart'; -import 'package:diplomaticquarterapp/pages/login/register.dart'; +import 'package:diplomaticquarterapp/pages/login/register_new.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart'; @@ -71,7 +71,7 @@ class LoginType extends StatelessWidget { width: double.infinity, child: FlatButton( onPressed: () { - Navigator.of(context).push(FadePage(page: Register())); + Navigator.of(context).push(FadePage(page: RegisterNew())); }, child: Text( TranslationBase.of(context).registerNow, diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 9c245e01..8fd61e4b 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -11,7 +11,7 @@ import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authent import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/login/confirm-login.dart'; import 'package:diplomaticquarterapp/pages/login/login-type.dart'; -import 'package:diplomaticquarterapp/pages/login/register.dart'; +import 'package:diplomaticquarterapp/pages/login/register_new.dart'; import 'package:diplomaticquarterapp/pages/rateAppointment/rate_appointment_doctor.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; @@ -104,9 +104,6 @@ class _Login extends State { style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16), ), SizedBox(height: 20), - // inputWidget("Country", "Saudi Arabia", isEnable: false, hasSelection: true), - // SizedBox(height: 12), - // inputWidget("Phone Number", "5xxxxxxxx", prefix: countryCode), PhoneNumberSelectorWidget(onNumberChange: (value) => {mobileNo = value, validateForm()}, onCountryChange: (value) => countryCode = value), SizedBox(height: 12), Directionality( @@ -274,7 +271,7 @@ class _Login extends State { cancelText: TranslationBase.of(context).cancel_nocaps, okFunction: () => { ConfirmDialog.closeAlertDialog(context), - Navigator.of(context).push(FadePage(page: Register())), + Navigator.of(context).push(FadePage(page: RegisterNew())), }, cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)}); dialog.showAlertDialog(context); diff --git a/lib/pages/login/register-info.dart b/lib/pages/login/register-info.dart index 4691983c..341f6098 100644 --- a/lib/pages/login/register-info.dart +++ b/lib/pages/login/register-info.dart @@ -1,14 +1,18 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; -import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/locator.dart'; +import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; +import 'package:diplomaticquarterapp/pages/rateAppointment/rate_appointment_doctor.dart'; +import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/appointment_rate_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/locator.dart'; -import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart' - as checkActivation; +import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart' as checkActivation; import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/register_info_response.dart'; -import 'package:diplomaticquarterapp/routes.dart'; +import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; @@ -17,7 +21,6 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; -import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:flutter/cupertino.dart'; @@ -25,8 +28,12 @@ import 'package:flutter/material.dart'; import 'package:hijri/hijri_calendar.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; class RegisterInfo extends StatefulWidget { + final Function changePageViewIndex; + final int page; + const RegisterInfo({Key key, this.changePageViewIndex, this.page = 1}) : super(key: key); @override _RegisterInfo createState() => _RegisterInfo(); } @@ -36,7 +43,7 @@ class _RegisterInfo extends State { final sharedPref = new AppSharedPreferences(); RegisterInfoResponse registerInfo; bool isLoading; - int page = 1; + int page; final List locationList = [ new Location(name: 'KSA', value: '1'), new Location(name: 'Dubai', value: '2'), @@ -49,240 +56,339 @@ class _RegisterInfo extends State { ]; String email = ''; + ToDoCountProviderModel toDoProvider; String location = '1'; - AuthenticatedUserObject authenticatedUserObject = - locator(); + AuthenticatedUserObject authenticatedUserObject = locator(); ProjectViewModel projectViewModel; - AppointmentRateViewModel appointmentRateViewModel = - locator(); + AppointmentRateViewModel appointmentRateViewModel = locator(); @override void initState() { WidgetsBinding.instance.addPostFrameCallback((timeStamp) { getRegisterInfo(); }); + setState(() { + page = widget.page; + }); + super.initState(); } @override Widget build(BuildContext context) { projectViewModel = Provider.of(context); - + toDoProvider = Provider.of(context); return AppScaffold( appBarTitle: TranslationBase.of(context).register, - isShowAppBar: true, + isShowAppBar: false, isShowDecPage: false, body: SingleChildScrollView( - padding: EdgeInsets.all(20), - child: Column(children: [ - AppText( - TranslationBase.of(context).patientInfo, - fontSize: SizeConfig.textMultiplier * 3, - textAlign: TextAlign.left, + padding: EdgeInsets.all(30), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Row( + children: [ + Expanded( + child: AppText( + TranslationBase.of(context).personalInfo, + fontSize: 16, + textAlign: TextAlign.left, + fontWeight: FontWeight.bold, + ), + ), + Expanded(child: SizedBox()) + ], ), + SizedBox(height: 20), registerInfo != null && page == 1 ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - AppText(TranslationBase.of(context).nationalID), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: registerInfo.idNumber, - prefixIcon: Icon(Icons.chrome_reader_mode, - color: Colors.red), - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - AppText(TranslationBase.of(context).firstName), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: registerInfo.firstNameEn == '-' - ? registerInfo.firstNameAr - : registerInfo.firstNameEn, - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - AppText(TranslationBase.of(context).middleName), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: registerInfo.secondNameEn == '-' - ? registerInfo.secondNameAr - : registerInfo.secondNameEn, - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - AppText(TranslationBase.of(context).lastName), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: registerInfo.lastNameEn == '-' - ? registerInfo.lastNameAr - : registerInfo.lastNameEn, - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - AppText(TranslationBase.of(context).gender), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: registerInfo.maritalStatusCode == 'U' - ? 'Unknown' - : registerInfo.maritalStatusCode == 'M' - ? 'Male' - : 'Female', - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - AppText(TranslationBase.of(context).maritalStatus), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: registerInfo.maritalStatus, - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - AppText(TranslationBase.of(context).nationality), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: registerInfo.nationalityCode, - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - AppText(TranslationBase.of(context).mobileNumber), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: - registerd_data.patientMobileNumber.toString(), - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - AppText(TranslationBase.of(context).dob), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: registerInfo.dateOfBirth, - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), + children: [ + SizedBox(height: 20), + getnameField(TranslationBase.of(context).identificationNumber, registerInfo.idNumber, TranslationBase.of(context).firstName, + registerInfo.firstNameEn == '-' ? registerInfo.firstNameAr : registerInfo.firstNameEn), + SizedBox(height: 20), + getnameField(TranslationBase.of(context).middleName, registerInfo.secondNameEn == '-' ? registerInfo.secondNameEn : registerInfo.secondNameEn, + TranslationBase.of(context).lastName, registerInfo.lastNameEn == '-' ? registerInfo.lastNameEn : registerInfo.lastNameEn), + SizedBox(height: 20), + getnameField( + TranslationBase.of(context).gender, + registerInfo.maritalStatusCode == 'U' + ? 'Unknown' + : registerInfo.maritalStatusCode == 'M' + ? 'Male' + : 'Female', + TranslationBase.of(context).maritalStatus, + registerInfo.maritalStatus), + SizedBox(height: 20), + getnameField(TranslationBase.of(context).nationality, registerInfo.nationality, TranslationBase.of(context).mobileNumber, registerd_data.patientMobileNumber.toString()), + SizedBox(height: 20), + getnameField(TranslationBase.of(context).dateOfBirth, registerInfo.dateOfBirth, "", ""), + SizedBox(height: 20), ], ) - : registerInfo != null && page == 2 + // Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // mainAxisAlignment: MainAxisAlignment.spaceEvenly, + // children: [ + // AppText(TranslationBase.of(context).nationalID), + // Container( + // margin: EdgeInsets.only(bottom: 10), + // child: TextFields( + // hintText: registerInfo.idNumber, + // prefixIcon: Icon(Icons.chrome_reader_mode, color: Colors.red), + // padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + // readOnly: true, + // )), + // AppText(TranslationBase.of(context).firstName), + // Container( + // margin: EdgeInsets.only(bottom: 10), + // child: TextFields( + // hintText: registerInfo.firstNameEn == '-' ? registerInfo.firstNameAr : registerInfo.firstNameEn, + // padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + // readOnly: true, + // )), + // AppText(TranslationBase.of(context).middleName), + // Container( + // margin: EdgeInsets.only(bottom: 10), + // child: TextFields( + // hintText: registerInfo.secondNameEn == '-' ? registerInfo.secondNameAr : registerInfo.secondNameEn, + // padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + // readOnly: true, + // )), + // AppText(TranslationBase.of(context).lastName), + // Container( + // margin: EdgeInsets.only(bottom: 10), + // child: TextFields( + // hintText: registerInfo.lastNameEn == '-' ? registerInfo.lastNameAr : registerInfo.lastNameEn, + // padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + // readOnly: true, + // )), + // AppText(TranslationBase.of(context).gender), + // Container( + // margin: EdgeInsets.only(bottom: 10), + // child: TextFields( + // hintText: registerInfo.maritalStatusCode == 'U' + // ? 'Unknown' + // : registerInfo.maritalStatusCode == 'M' + // ? 'Male' + // : 'Female', + // padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + // readOnly: true, + // )), + // AppText(TranslationBase.of(context).maritalStatus), + // Container( + // margin: EdgeInsets.only(bottom: 10), + // child: TextFields( + // hintText: registerInfo.maritalStatus, + // padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + // readOnly: true, + // )), + // AppText(TranslationBase.of(context).nationality), + // Container( + // margin: EdgeInsets.only(bottom: 10), + // child: TextFields( + // hintText: registerInfo.nationalityCode, + // padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + // readOnly: true, + // )), + // AppText(TranslationBase.of(context).mobileNumber), + // Container( + // margin: EdgeInsets.only(bottom: 10), + // child: TextFields( + // hintText: registerd_data.patientMobileNumber.toString(), + // padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + // readOnly: true, + // )), + // AppText(TranslationBase.of(context).dob), + // Container( + // margin: EdgeInsets.only(bottom: 10), + // child: TextFields( + // hintText: registerInfo.dateOfBirth, + // padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + // readOnly: true, + // )), + // ], + // ) + + : registerInfo != null && widget.page == 2 ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - AppText(TranslationBase.of(context).language, - textAlign: TextAlign.start), Container( - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Colors.white, - border: Border.all(color: Colors.grey), - borderRadius: BorderRadius.circular(10)), - child: DropdownButtonHideUnderline( - child: DropdownButton( - isExpanded: true, - value: language, - iconSize: 40, - elevation: 16, - onChanged: (value) => { - setState(() { - language = value; - }) - }, - items: languageList - .map>( - (Language value) { - return DropdownMenuItem( - value: value.value, - child: Text(value.name), - ); - }).toList()))), - AppText(TranslationBase.of(context).location), + width: double.infinity, + decoration: containerRadius(Colors.white, 12), + padding: EdgeInsets.only(left: 10, right: 10, top: 5, bottom: 25), + child: Row(children: [ + Flexible( + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + TranslationBase.of(context).prefferedLanguage, + style: TextStyle( + fontSize: 11, + letterSpacing: -0.44, + fontWeight: FontWeight.w600, + ), + ), + Container( + height: 18, + child: DropdownButtonHideUnderline( + child: DropdownButton( + isExpanded: true, + value: language, + hint: Text(TranslationBase.of(context).prefferedLanguage), + iconSize: 40, + elevation: 16, + onChanged: (value) => { + setState(() { + language = value; + }) + }, + items: languageList.map>((Language value) { + return DropdownMenuItem( + value: value.value, + child: Text(value.name), + ); + }).toList()))) + ])) + ])), + SizedBox( + height: 20, + ), Container( - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Colors.white, - border: Border.all(color: Colors.grey), - borderRadius: BorderRadius.circular(10)), - child: DropdownButtonHideUnderline( - child: DropdownButton( - isExpanded: true, - value: location, - iconSize: 40, - elevation: 16, - onChanged: (value) => { - setState(() { - location = value; - }) - }, - items: locationList - .map>( - (Location value) { - return DropdownMenuItem( - value: value.value, - child: Text(value.name), - ); - }).toList()))), - AppText(TranslationBase.of(context).email), + width: double.infinity, + decoration: containerRadius(Colors.white, 12), + padding: EdgeInsets.only(left: 10, right: 10, top: 5, bottom: 25), + child: Row(children: [ + Flexible( + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + TranslationBase.of(context).selectLocation, + style: TextStyle( + fontSize: 11, + letterSpacing: -0.44, + fontWeight: FontWeight.w600, + ), + ), + Container( + height: 18, + child: DropdownButtonHideUnderline( + child: DropdownButton( + isExpanded: true, + value: location, + hint: Text(TranslationBase.of(context).selectLocation), + iconSize: 40, + elevation: 16, + onChanged: (value) => { + setState(() { + location = value; + }) + }, + items: locationList.map>((Location value) { + return DropdownMenuItem( + value: value.value, + child: Text( + value.name, + ), + ); + }).toList()))) + ])) + ])), + SizedBox( + height: 20, + ), Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - onChanged: (value) => { - setState(() { - email = value; - }) - }, - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - )), + width: double.infinity, + decoration: containerRadius(Colors.white, 12), + padding: EdgeInsets.only(left: 10, right: 10, top: 5, bottom: 12), + margin: EdgeInsets.only(bottom: 0), + child: Row(children: [ + Flexible( + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + TranslationBase.of(context).email, + style: TextStyle( + fontSize: 11, + letterSpacing: -0.44, + fontWeight: FontWeight.w600, + ), + ), + Container( + child: TextField( + onChanged: (value) { + setState(() { + email = value; + }); + }, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + )) + ])) + ])), ], ) : SizedBox(), - Column( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Row( - children: [ - Expanded( - child: DefaultButton( - page == 1 - ? TranslationBase.of(context).next - : TranslationBase.of(context).register, - () => {nextPage()}, - textColor: Colors.white, - color: this.isValid() == false && page == 2 - ? Colors.grey - : Colors.black, - )) - ], + // Column( + // mainAxisAlignment: MainAxisAlignment.end, + // children: [ + // Row( + // children: [ + // Expanded( + // child: DefaultButton( + // page == 1 ? TranslationBase.of(context).next : TranslationBase.of(context).register, + // () => {nextPage()}, + // textColor: Colors.white, + // color: this.isValid() == false && page == 2 ? Colors.grey : Colors.black, + // )) + // ], + // ), + // ], + // ) + ]), + ), + bottomSheet: Container( + width: double.maxFinite, + height: 80.0, + child: Row( + children: [ + Expanded( + child: Padding( + padding: EdgeInsets.all(10), child: DefaultButton(TranslationBase.of(context).cancel, () => {Navigator.of(context).pop()}, textColor: Colors.white, color: Color(0xffD02127))), + ), + Expanded( + child: Padding( + padding: EdgeInsets.all(10), + child: DefaultButton(page == 1 ? TranslationBase.of(context).next : TranslationBase.of(context).register, () => {nextPage()}, + textColor: Colors.white, color: isValid() == true && page == 2 || page == 1 ? Color(0xff359846) : Colors.grey)), ), ], - ) - ]), - )); + ))); } nextPage() { if (page == 1) { setState(() { - page++; + widget.changePageViewIndex(2); }); } else { registerNow(); @@ -292,6 +398,7 @@ class _RegisterInfo extends State { registerNow() { dynamic request = getTempUserRequest(); GifLoaderDialogUtils.showMyDialog(context); + dynamic res; this .authService .registerUser(request) @@ -306,21 +413,31 @@ class _RegisterInfo extends State { confirmMessage: result, okText: TranslationBase.of(context).ok, cancelText: TranslationBase.of(context).cancel_nocaps, - okFunction: () => - {ConfirmDialog.closeAlertDialog(context)}, - cancelFunction: () => { - ConfirmDialog.closeAlertDialog(context) - }).showAlertDialog(context) + okFunction: () => {ConfirmDialog.closeAlertDialog(context)}, + cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)}).showAlertDialog(context) } else { + res = result, result = checkActivation.CheckActivationCode.fromJson(result), + // result.list.isFamily = false, + // sharedPref.setObject(USER_PROFILE, result.list), + // this.sharedPref.setObject(MAIN_USER, result.list), + // sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), + // sharedPref.setString(TOKEN, result.authenticationTokenID), + // this.setUser(result), + sharedPref.remove(FAMILY_FILE), result.list.isFamily = false, + + sharedPref.setString(BLOOD_TYPE, result.patientBloodType), + authenticatedUserObject.user = result.list, + projectViewModel.setPrivilege(privilegeList: res), + sharedPref.setObject(MAIN_USER, result.list), sharedPref.setObject(USER_PROFILE, result.list), - this.sharedPref.setObject(MAIN_USER, result.list), + sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), sharedPref.setString(TOKEN, result.authenticationTokenID), - this.setUser(result), + checkIfUserAgreedBefore(result), } }) .catchError((err) { @@ -346,11 +463,9 @@ class _RegisterInfo extends State { } getRegisterInfo() async { - var data = - RegisterInfoResponse.fromJson(await sharedPref.getObject(NHIC_DATA)); + var data = RegisterInfoResponse.fromJson(await sharedPref.getObject(NHIC_DATA)); if (await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN) != null) { - var data2 = CheckPatientAuthenticationReq.fromJson( - await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN)); + var data2 = CheckPatientAuthenticationReq.fromJson(await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN)); setState(() { this.registerInfo = data; @@ -363,8 +478,7 @@ class _RegisterInfo extends State { getTempUserRequest() { DateFormat dateFormat = DateFormat("mm/dd/yyyy"); print(dateFormat.parse(registerInfo.dateOfBirth)); - var hDate = - new HijriCalendar.fromDate(dateFormat.parse(registerInfo.dateOfBirth)); + var hDate = new HijriCalendar.fromDate(dateFormat.parse(registerInfo.dateOfBirth)); var date = hDate.toString(); return { "Patientobject": { @@ -380,8 +494,7 @@ class _RegisterInfo extends State { "LastNameN": registerInfo.lastNameAr, "LastName": registerInfo.lastNameEn, "StrDateofBirth": registerInfo.dateOfBirth, - "DateofBirth": DateUtil.convertISODateToJsonDate( - registerInfo.dateOfBirth.replaceAll('/', '-')), + "DateofBirth": DateUtil.convertISODateToJsonDate(registerInfo.dateOfBirth.replaceAll('/', '-')), "Gender": registerInfo.gender == 'M' ? 1 : 2, "NationalityID": registerInfo.nationalityCode, "eHealthIDField": registerInfo.healthId, @@ -396,19 +509,116 @@ class _RegisterInfo extends State { : '2', }, "PatientIdentificationID": registerInfo.idNumber, - "PatientMobileNumber": registerd_data.patientMobileNumber, + "PatientMobileNumber": registerd_data.patientMobileNumber.toString()[0] == '0' ? registerd_data.patientMobileNumber : '0' + registerd_data.patientMobileNumber.toString(), }; } bool isValid() { - if (location != null || - language != null || - Utils.validEmail(email) == true) { + if (location != null && language != null && Utils.validEmail(email) == true) { return true; } else { return false; } } + + Widget getnameField(name1, value1, name2, value2) { + return Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + name1, + fontSize: 12, + fontWeight: FontWeight.bold, + ), + AppText( + value1, + ), + ], + )), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + name2, + fontSize: 12, + fontWeight: FontWeight.bold, + ), + AppText(value2), + ], + )) + ], + ); + } + + checkIfUserAgreedBefore(checkActivation.CheckActivationCode result) { + if (result.isNeedUserAgreement == true) { + //need to implement agreement page here + insertIMEI(); + } else { + insertIMEI(); + } + } + + insertIMEI() async { + var selectedOption = await sharedPref.getInt(LAST_LOGIN); + authService.insertDeviceImei(selectedOption).then((value) => {goToHome()}).catchError((err) { + print(err); + }); + // authService.registeredAuthenticatedUser(data, token, 0, 0).then((res) => {}); + } + + goToHome() async { + authenticatedUserObject.isLogin = true; + appointmentRateViewModel.isLogin = true; + projectViewModel.isLogin = true; + projectViewModel.user = authenticatedUserObject.user; + await authenticatedUserObject.getUser(getUser: true); + appointmentRateViewModel + .getIsLastAppointmentRatedList() + .then((value) => { + getToDoCount(), + GifLoaderDialogUtils.hideDialog(AppGlobal.context), + if (appointmentRateViewModel.isHaveAppointmentNotRate) + { + Navigator.pushAndRemoveUntil( + context, + FadePage( + page: RateAppointmentDoctor(), + ), + (r) => false) + } + else + { + Navigator.pushAndRemoveUntil( + context, + FadePage( + page: LandingPage(), + ), + (r) => false) + } + }) + .catchError((err) { + print(err); + //GifLoaderDialogUtils.hideDialog(context); + }); + // SMSOTP.showLoadingDialog(context, false), + } + + getToDoCount() { + toDoProvider.setState(0, true, "0"); + ClinicListService service = new ClinicListService(); + service.getActiveAppointmentNo(context).then((res) { + if (res['MessageStatus'] == 1) { + toDoProvider.setState(res['AppointmentActiveNumber'], true, "0"); + } else {} + }).catchError((err) { + print(err); + }); + } } class Language { diff --git a/lib/pages/login/register.dart b/lib/pages/login/register.dart index 012669c7..52bfe5a5 100644 --- a/lib/pages/login/register.dart +++ b/lib/pages/login/register.dart @@ -21,9 +21,14 @@ import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; +import 'package:intl/intl.dart' as intl; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; class Register extends StatefulWidget { + final Function changePageViewIndex; + const Register({Key key, this.changePageViewIndex}) : super(key: key); + @override _Register createState() => _Register(); } @@ -36,7 +41,9 @@ class _Register extends State { var isHijri; final util = Utils(); DateTime selectedDate; - String dob; + TextEditingController dob = TextEditingController(); + TextEditingController dobEn = TextEditingController(); + bool isButtonDisabled = true; final authService = new AuthProvider(); final sharedPref = new AppSharedPreferences(); @@ -47,8 +54,10 @@ class _Register extends State { Widget build(BuildContext context) { return AppScaffold( appBarTitle: TranslationBase.of(context).register, - isShowAppBar: true, + isShowAppBar: false, isShowDecPage: false, + showNewAppBar: false, + showNewAppBarTitle: true, body: SingleChildScrollView( child: Container( padding: EdgeInsets.only(top: 10, left: 20, right: 20, bottom: 30), @@ -56,27 +65,22 @@ class _Register extends State { width: SizeConfig.realScreenWidth, child: Column(children: [ Expanded( - flex: 1, - child: AppText( - TranslationBase.of(context).enterNationalId, - fontSize: SizeConfig.textMultiplier * 3, - textAlign: TextAlign.left, - )), - Expanded( - flex: 4, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - MobileNo(onNumberChange: (value) => {mobileNo = value, validateForm()}, onCountryChange: (value) => countryCode = value), - Container( - child: TextFields( - controller: nationalIDorFile, - onChanged: (value) => validateForm(), - keyboardType: TextInputType.number, - prefixIcon: Icon(Icons.chrome_reader_mode, color: Color(0xFF40ACC9)), - padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), - hintText: TranslationBase.of(context).nationalID, - )), + child: ListView( + padding: EdgeInsets.zero, + physics: BouncingScrollPhysics(), + children: [ + SizedBox(height: 10), + Padding( + padding: EdgeInsets.all(10), + child: Text( + TranslationBase.of(context).enterNationalId, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16), + )), + SizedBox(height: 10), + PhoneNumberSelectorWidget(onNumberChange: (value) => {mobileNo = value, validateForm()}, onCountryChange: (value) => countryCode = value), + SizedBox(height: 12), + Directionality(textDirection: TextDirection.ltr, child: inputWidget(TranslationBase.of(context).nationalIdNumber, "Xxxxxxxxx", nationalIDorFile)), + SizedBox(height: 20), Row( children: [ Expanded( @@ -115,63 +119,270 @@ class _Register extends State { ), ], ), - Row(mainAxisAlignment: MainAxisAlignment.end, children: [ + Row(children: [ Container( width: SizeConfig.realScreenWidth * .9, - height: 60, child: isHijri == 1 - ? TextFields( - onChanged: (value) => {dob = value}, - hintText: 'DD/MM/YYYY', - prefixIcon: Icon(Icons.date_range), - ) - : RaisedButton.icon( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(15.0), - ), - color: Colors.white, - onPressed: () => {if (isHijri != null) _selectDate(context)}, - icon: Icon(Icons.date_range), - label: Text(selectedDate != null ? "${selectedDate.toLocal()}".split(' ')[0] : TranslationBase.of(context).dob))) + ? Directionality( + textDirection: TextDirection.ltr, + child: inputWidget(TranslationBase.of(context).dob, "DD/MM/YYYYY", dob, + isNumber: false, + suffix: Icon( + Icons.calendar_today, + size: 16, + ))) + : + + // ? TextFields( + // onChanged: (value) => {dob = value}, + // hintText: 'DD/MM/YYYY', + // suffixIcon: Icons.date_range, + // hintColor: Colors.black, + // ) + // ? Directionality(textDirection: TextDirection.ltr, child: inputWidget(TranslationBase.of(context).dob, "DD/MM/YYYY", dob)) + + // ? Container( + // padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + // alignment: Alignment.center, + // decoration: BoxDecoration( + // borderRadius: BorderRadius.circular(15), + // color: Colors.white, + // border: Border.all( + // color: Color(0xffefefef), + // width: 1, + // ), + // ), + // child: InkWell( + // onTap: () {}, + // child: Row( + // children: [ + // Expanded( + // child: Column( + // mainAxisSize: MainAxisSize.min, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // TranslationBase.of(context).dob, + // style: TextStyle( + // fontSize: 11, + // fontWeight: FontWeight.w600, + // color: Color(0xff2B353E), + // letterSpacing: -0.44, + // ), + // ), + // TextField( + // scrollPadding: EdgeInsets.zero, + // keyboardType: TextInputType.number, + // decoration: InputDecoration( + // suffix: Icon(Icons.date_range), + // contentPadding: EdgeInsets.zero, + // border: InputBorder.none, + // focusedBorder: InputBorder.none, + // enabledBorder: InputBorder.none, + // ), + // maxLines: , + // onChanged: (value) => {dob = value}, + // style: TextStyle( + // fontSize: 14, + // height: 21 / 14, + // fontWeight: FontWeight.w400, + // color: Color(0xff2B353E), + // letterSpacing: -0.44, + // ), + // ), + // ], + // ), + // ), + // ], + // ), + // ), + // ) + Container( + child: InkWell( + onTap: () { + if (isHijri != null) _selectDate(context); + }, + child: Directionality( + textDirection: TextDirection.ltr, + child: inputWidget(TranslationBase.of(context).dob, "DD/MM/YYYYY", dobEn, + isNumber: false, + isEnable: false, + suffix: Icon( + Icons.calendar_today, + size: 16, + )))))), + + // RaisedButton.icon( + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(15.0), + // ), + + // color: Colors.white, + // onPressed: () => }, + // icon: Icon(Icons.date_range), + // label: Text(selectedDate != null ? "${selectedDate.toLocal()}".split(' ')[0] : TranslationBase.of(context).dob))) ]) ], ), ), - Expanded( - flex: 2, - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Divider( - color: Colors.grey, - height: 2, - ), - SizedBox( - height: 10, - ), - Row( - children: [ - Expanded( - child: DefaultButton(TranslationBase.of(context).registerNow, () => {startRegistration()}, - textColor: Colors.white, color: isButtonDisabled == true ? Colors.grey : Colors.grey[900])) - ], - ), - ], - )) + // Expanded( + // child: Column( + // mainAxisAlignment: MainAxisAlignment.spaceEvenly, + // children: [ + // // MobileNo(onNumberChange: (value) => {mobileNo = value, validateForm()}, onCountryChange: (value) => countryCode = value), + // // Container( + // // child: TextFields( + // // controller: nationalIDorFile, + // // onChanged: (value) => validateForm(), + // // keyboardType: TextInputType.number, + // // prefixIcon: Icon(Icons.chrome_reader_mode, color: Color(0xFF40ACC9)), + // // padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + // // hintText: TranslationBase.of(context).nationalID, + // // )), + // ], + // ), + // ), + // Column( + // mainAxisAlignment: MainAxisAlignment.end, + // children: [ + // Divider( + // color: Colors.grey, + // height: 2, + // ), + // SizedBox( + // height: 10, + // ), + // Row( + // children: [ + // Expanded( + // child:) + // ], + // ), + // ], + // )) ]), - ))); + )), + bottomSheet: Container( + width: double.maxFinite, + height: 80.0, + child: Row( + children: [ + Expanded( + child: Padding( + padding: EdgeInsets.all(10), child: DefaultButton(TranslationBase.of(context).cancel, () => {Navigator.of(context).pop()}, textColor: Colors.white, color: Color(0xffD02127))), + ), + Expanded( + child: Padding( + padding: EdgeInsets.all(10), + child: DefaultButton(TranslationBase.of(context).next, () => {startRegistration()}, textColor: Colors.white, color: isButtonDisabled == true ? Colors.grey : Color(0xff359846))), + ), + ], + ))); } Future _selectDate(BuildContext context) async { - final DateTime picked = await showDatePicker(context: context, initialDate: DateTime.now(), firstDate: DateTime(1950, 8), lastDate: DateTime.now()); - if (picked != null && picked != selectedDate) - setState(() { - selectedDate = picked; - }); + DatePicker.showDatePicker( + context, + showTitleActions: true, + minTime: DateTime(DateTime.now().year - 100, 1, 1), + maxTime: DateTime.now(), + onConfirm: (date) { + selectedDate = date; + setState(() { + final intl.DateFormat dateFormat = intl.DateFormat('dd/MM/yyyy'); + dobEn.text = dateFormat.format(date); + }); + }, + currentTime: DateTime.now(), + ); + } + + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false, bool isNumber = true, Icon suffix}) { + return Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: InkWell( + onTap: hasSelection ? () {} : null, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: isNumber ? TextInputType.number : TextInputType.datetime, + controller: _controller, + onChanged: (value) => {validateForm()}, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + prefixIcon: prefix == null + ? null + : Text( + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], + ), + ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + if (suffix != null) suffix + ], + ), + ), + ); } startRegistration() { - final DateFormat dateFormat = DateFormat('dd/MM/yyyy'); + final intl.DateFormat dateFormat = intl.DateFormat('dd/MM/yyyy'); if (isButtonDisabled == false) { var request = CheckPatientForRegistration(); request.patientMobileNumber = int.parse(mobileNo); @@ -181,7 +392,7 @@ class _Register extends State { request.patientIdentificationID = int.parse(nationalIDorFile.text); request.patientID = 0; request.isRegister = true; - request.dob = isHijri == 1 ? dob : dateFormat.format(selectedDate); + request.dob = isHijri == 1 ? dob.text : dateFormat.format(selectedDate); request.isHijri = isHijri; this.checkPatientForRegisteration(request); } @@ -206,7 +417,11 @@ class _Register extends State { } void validateForm() { - if (util.validateIDBox(nationalIDorFile.text, loginType) == true && mobileNo.length >= 9 && util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true && isHijri != null) { + if (util.validateIDBox(nationalIDorFile.text, loginType) == true && + mobileNo.length >= 9 && + util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true && + isHijri != null && + (dobEn.text != null || dob.text != null)) { setState(() { isButtonDisabled = false; }); @@ -265,11 +480,11 @@ class _Register extends State { // IsHijri: Number(this.dateOption) // } - final DateFormat dateFormat = DateFormat('dd/MM/yyyy'); + final intl.DateFormat dateFormat = intl.DateFormat('dd/MM/yyyy'); GifLoaderDialogUtils.showMyDialog(context); var request = CheckUserStatusRequest(); request.patientIdentificationID = nationalIDorFile.text; - request.dOB = isHijri == 1 ? dob : dateFormat.format(selectedDate); + request.dOB = isHijri == 1 ? dob.text : dateFormat.format(selectedDate); request.isHijri = isHijri; request.patientOutSA = countryCode == '966' ? 0 : 1; this.authService.checkUserStatus(request).then((result) => { @@ -278,16 +493,10 @@ class _Register extends State { { result = CheckUserStatusResponse.fromJson(result), sharedPref.setObject(NHIC_DATA, result), - Navigator.of(context).push(FadePage(page: ConfirmLogin())), + Navigator.of(context).push(FadePage(page: ConfirmLogin(changePageViewIndex: widget.changePageViewIndex))), } else {AppToast.showErrorToast(message: result ? result : TranslationBase.of(context).somethingWentWrong)} }); } - - showLoader(bool isTrue) { - setState(() { - isLoading = isTrue; - }); - } } diff --git a/lib/pages/login/register_new.dart b/lib/pages/login/register_new.dart new file mode 100644 index 00000000..f51b1b82 --- /dev/null +++ b/lib/pages/login/register_new.dart @@ -0,0 +1,203 @@ +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/pages/login/login-type.dart'; +import 'package:diplomaticquarterapp/pages/login/register.dart'; +import 'package:diplomaticquarterapp/pages/login/register-info.dart'; +import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; +import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/pages/login/confirm-login.dart'; + +class RegisterNew extends StatefulWidget { + @override + _RegisterNew createState() => _RegisterNew(); +} + +class _RegisterNew extends State { + final nationalIDorFile = TextEditingController(); + final int loginType = LoginType.loginType; + String mobileNo; + String countryCode = '966'; + var isHijri; + final util = Utils(); + DateTime selectedDate; + String dob; + bool isButtonDisabled = true; + final authService = new AuthProvider(); + final sharedPref = new AppSharedPreferences(); + PageController _controller; + bool isLoading; + int _currentIndex = 0; + + @override + void initState() { + super.initState(); + _controller = new PageController(); + } + + @override + void dispose() { + super.dispose(); + } + + changePageViewIndex(pageIndex) { + _controller.jumpToPage(pageIndex); + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + appBarTitle: TranslationBase.of(context).register, + isShowAppBar: true, + isShowDecPage: false, + showNewAppBar: true, + showNewAppBarTitle: true, + body: SingleChildScrollView( + child: Container( + height: SizeConfig.realScreenHeight * .9, + width: SizeConfig.realScreenWidth, + child: Column(children: [ + Container( + width: double.infinity, + padding: EdgeInsets.only(left: 20, right: 20, top: 12), + child: Row( + children: [ + Expanded( + child: showProgress( + title: TranslationBase.of(context).RequesterInfo, + status: _currentIndex == 0 + ? TranslationBase.of(context).inPrgress + : _currentIndex > 0 + ? TranslationBase.of(context).completed + : TranslationBase.of(context).locked, + color: _currentIndex == 0 ? CustomColors.orange : CustomColors.green, + ), + ), + Expanded( + child: showProgress( + title: TranslationBase.of(context).patientInfo, + status: _currentIndex == 1 + ? TranslationBase.of(context).inPrgress + : _currentIndex > 1 + ? TranslationBase.of(context).completed + : TranslationBase.of(context).locked, + color: _currentIndex == 1 + ? CustomColors.orange + : _currentIndex > 1 + ? CustomColors.green + : CustomColors.grey2, + ), + ), + showProgress( + title: TranslationBase.of(context).otherInfo, + status: _currentIndex == 2 ? TranslationBase.of(context).inPrgress : TranslationBase.of(context).locked, + color: _currentIndex == 2 + ? CustomColors.orange + : _currentIndex > 3 + ? CustomColors.green + : CustomColors.grey2, + isNeedBorder: false, + ), + ], + ), + ), + Expanded( + child: PageView( + physics: NeverScrollableScrollPhysics(), + controller: _controller, + onPageChanged: (index) { + setState(() { + _currentIndex = index; + }); + }, + scrollDirection: Axis.horizontal, + children: [ + Register( + changePageViewIndex: changePageViewIndex, + ), + + RegisterInfo( + changePageViewIndex: changePageViewIndex, + ), + RegisterInfo(changePageViewIndex: changePageViewIndex, page: 2), + // NewEReferralStepOnePage( + // changePageViewIndex: changePageViewIndex, + // createEReferralRequestModel: createEReferralRequestModel, + // ), + // NewEReferralStepTowPage( + // changePageViewIndex: changePageViewIndex, + // createEReferralRequestModel: createEReferralRequestModel, + // ), + // NewEReferralStepThreePage( + // changePageViewIndex: changePageViewIndex, + // createEReferralRequestModel: createEReferralRequestModel, + // ), + ], + ), + ), + ]), + )), + ); + } + + Widget showProgress({String title, String status, Color color, bool isNeedBorder = true}) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + width: 26, + height: 26, + decoration: containerRadius(color, 200), + child: Icon( + Icons.done, + color: Colors.white, + size: 16, + ), + ), + if (isNeedBorder) + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: mDivider(Colors.grey), + )), + ], + ), + mHeight(8), + Text( + title, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + letterSpacing: -0.44, + ), + ), + mHeight(2), + Container( + padding: EdgeInsets.all(5), + decoration: containerRadius(color.withOpacity(0.2), 4), + child: Text( + status, + style: TextStyle( + fontSize: 8, + fontWeight: FontWeight.w600, + letterSpacing: -0.32, + color: color, + ), + ), + ), + ], + ) + ], + ); + } +} diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index af1fd3f6..3d759ce6 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request.dart'; +import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request_register.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_user_status_req.dart'; @@ -15,7 +16,7 @@ import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_re import 'package:diplomaticquarterapp/models/Request.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:flutter/cupertino.dart'; - +import 'package:intl/intl.dart'; import '../../locator.dart'; // SharedPreferences sharedPref = new SharedPreferences(); @@ -29,7 +30,11 @@ const String SELECT_DEVICE_IMEI = 'Services/Patients.svc/REST/Patient_SELECTDevi const String CHECK_PATIENT_AUTH = 'Services/Authentication.svc/REST/CheckPatientAuthentication'; const GET_MOBILE_INFO = 'Services/Authentication.svc/REST/GetMobileLoginInfo'; const SEND_ACTIVATION_CODE = 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationType'; + +const SEND_ACTIVATION_CODE_REGISTER = 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationTypeForRegistration'; const CHECK_ACTIVATION_CODE = 'Services/Authentication.svc/REST/CheckActivationCode'; +const CHECK_ACTIVATION_CODE_REGISTER = 'Services/Authentication.svc/REST/CheckActivationCodeForRegistration'; + const FORGOT_PASSWORD = 'Services/Authentication.svc/REST/CheckActivationCodeForSendFileNo'; const CHECK_PATIENT_FOR_REGISTRATION = "Services/Authentication.svc/REST/CheckPatientForRegisteration"; @@ -211,8 +216,29 @@ class AuthProvider with ChangeNotifier { return Future.value(localRes); } + Future sendActivationCodeRegister(request) async { + request.versionID = VERSION_ID; + request.channel = CHANNEL; + request.iPAdress = IP_ADDRESS; + request.generalid = GENERAL_ID; + request.languageID = LANGUAGE_ID; + request.deviceTypeID = DeviceTypeID; + request.patientOutSA = request.zipCode == '966' ? 0 : 1; + request.isDentalAllowedBackend = false; + + dynamic localRes; + await new BaseAppClient().post(SEND_ACTIVATION_CODE_REGISTER, onSuccess: (dynamic response, int statusCode) { + localRes = response; + authenticatedUser = CheckActivationCode.fromJson(localRes); + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request.toJson()); + return Future.value(localRes); + } + Future checkActivationCode(request, [value]) async { var neRequest = CheckActivationCodeReq.fromJson(request); + neRequest.activationCode = value ?? "0000"; neRequest.isSilentLogin = value != null ? false : true; neRequest.versionID = VERSION_ID; @@ -236,6 +262,38 @@ class AuthProvider with ChangeNotifier { return Future.value(error); // throw error; }, body: neRequest.toJson()); + return Future.value(localRes); + } catch (error) { + throw localRes; + } + } + + Future checkActivationCodeRegister(request, [value]) async { + var neRequest = CheckActivationCodeRegisterReq.fromJson(request); + + neRequest.activationCode = value ?? "0000"; + neRequest.isSilentLogin = value != null ? false : true; + neRequest.versionID = VERSION_ID; + neRequest.channel = CHANNEL; + neRequest.iPAdress = IP_ADDRESS; + neRequest.generalid = GENERAL_ID; + // neRequest.languageID = LANGUAGE_ID; + neRequest.deviceTypeID = DeviceTypeID; + neRequest.patientOutSA = neRequest.zipCode == '966' ? 0 : 1; + neRequest.projectOutSA = neRequest.zipCode == '966' ? false : true; + neRequest.isDentalAllowedBackend = false; + // neRequest.deviceToken = null; + neRequest.forRegisteration = neRequest.isRegister != null ? neRequest.isRegister : false; + neRequest.isRegister = false; + dynamic localRes; + try { + await new BaseAppClient().post(CHECK_ACTIVATION_CODE_REGISTER, onSuccess: (dynamic response, int statusCode) { + localRes = response; //CheckActivationCode.fromJson(); + }, onFailure: (String error, int statusCode) { + localRes = error; + return Future.value(error); + // throw error; + }, body: neRequest.toJson()); // sharedPref.setString(BLOOD_TYPE, localRes['PatientBloodType']); return Future.value(localRes); } catch (error) { @@ -302,10 +360,18 @@ class AuthProvider with ChangeNotifier { request['Generalid'] = GENERAL_ID; request['DeviceTypeID'] = DeviceTypeID; request['LanguageID'] = LANGUAGE_ID; + request['LogInTokenID'] = await sharedPref.getString(LOGIN_TOKEN_ID); + var nhic = await sharedPref.getObject(NHIC_DATA); var requestN = RegisterUserRequest.fromJson(request); requestN.patientOutSA = requestN.patientobject.patientOutSA; + final DateFormat dateFormat = DateFormat('MM/dd/yyyy'); + final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); + requestN.dob = nhic['IsHijri'] ? nhic['DateOfBirth'] : dateFormat2.format(dateFormat.parse(nhic['DateOfBirth'])); + requestN.zipCode = requestN.patientOutSA == 1 ? '971' : '966'; + requestN.healthId = requestN.patientobject.eHealthIDField; + requestN.isHijri = nhic['IsHijri'] ? 1 : 0; await sharedPref.remove(USER_PROFILE); - // request.tokenID = ''; + dynamic localRes; try { await new BaseAppClient().post(REGISTER_USER, onSuccess: (dynamic response, int statusCode) { diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 09b50632..aed37b8d 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2406,6 +2406,8 @@ class TranslationBase { String get inPrgress => localizedValues["inPrgress"][locale.languageCode]; String get locked => localizedValues["locked"][locale.languageCode]; + + String get personalInfo => localizedValues['personalInfo'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate {