From f8e05fc447d7769caa8fd14d5b8e60b62139f309 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Thu, 5 Nov 2020 15:46:01 +0300 Subject: [PATCH 1/3] regiter issue --- lib/config/localized_values.dart | 1 + .../components/DocAvailableAppointments.dart | 2 +- .../Covid-DriveThru/Covid-TimeSlots.dart | 7 +- lib/pages/login/register-info.dart | 205 ++++++++++++++++-- lib/uitl/translations_delegate_base.dart | 1 + lib/uitl/utils.dart | 6 + 6 files changed, 206 insertions(+), 16 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index fbdf2ab5..e2ce3de5 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -668,4 +668,5 @@ const Map> localizedValues = { "en": "Drag point to change your age", "ar": "اسحب لتغيير عمرك" }, + "email": {"en": "Email", "ar": "البريد الالكتروني"} }; diff --git a/lib/pages/BookAppointment/components/DocAvailableAppointments.dart b/lib/pages/BookAppointment/components/DocAvailableAppointments.dart index 3e9ae0cd..aca0884f 100644 --- a/lib/pages/BookAppointment/components/DocAvailableAppointments.dart +++ b/lib/pages/BookAppointment/components/DocAvailableAppointments.dart @@ -235,7 +235,7 @@ class _DocAvailableAppointmentsState extends State return children; }, ), - onDaySelected: (date, events,format) { + onDaySelected: (date, events) { _onDaySelected(date, events); _animationController.forward(from: 0.0); }, diff --git a/lib/pages/Covid-DriveThru/Covid-TimeSlots.dart b/lib/pages/Covid-DriveThru/Covid-TimeSlots.dart index 9f2418fd..939198c3 100644 --- a/lib/pages/Covid-DriveThru/Covid-TimeSlots.dart +++ b/lib/pages/Covid-DriveThru/Covid-TimeSlots.dart @@ -348,8 +348,11 @@ class _CovidTimeSlotsState extends State return children; }, ), - onDaySelected: (date, event,formats) { - _onDaySelected(date, event,); + onDaySelected: (date, event) { + _onDaySelected( + date, + event, + ); _animationController.forward(from: 0.0); }, onVisibleDaysChanged: _onVisibleDaysChanged, diff --git a/lib/pages/login/register-info.dart b/lib/pages/login/register-info.dart index e94c1af6..2bbd1007 100644 --- a/lib/pages/login/register-info.dart +++ b/lib/pages/login/register-info.dart @@ -1,6 +1,8 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/register_info_response.dart'; +import 'package:diplomaticquarterapp/models/Authentication/register_user_requet.dart'; import 'package:diplomaticquarterapp/pages/login/login-type.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; @@ -28,6 +30,19 @@ class _RegisterInfo extends State { RegisterInfoResponse registerInfo; bool isLoading; int page = 1; + final List locationList = [ + new Location(name: 'KSA', value: '1'), + new Location(name: 'Dubai', value: '2'), + ]; + var language; + var registerd_data; + final List languageList = [ + new Language(name: 'English', value: '2'), + new Language(name: 'Arabic', value: '1'), + ]; + var email =''; + + var location; @override void initState() { getRegisterInfo(); @@ -58,7 +73,7 @@ class _RegisterInfo extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - AppText('National ID'), + AppText(TranslationBase.of(context).nationalID), Container( margin: EdgeInsets.only(bottom: 10), child: TextFields( @@ -69,7 +84,7 @@ class _RegisterInfo extends State { top: 20, bottom: 20, left: 10, right: 10), readOnly: true, )), - AppText('Name'), + AppText(TranslationBase.of(context).name), Container( margin: EdgeInsets.only(bottom: 10), child: TextFields( @@ -80,7 +95,7 @@ class _RegisterInfo extends State { top: 20, bottom: 20, left: 10, right: 10), readOnly: true, )), - AppText('Gender'), + AppText(TranslationBase.of(context).gender), Container( margin: EdgeInsets.only(bottom: 10), child: TextFields( @@ -93,7 +108,7 @@ class _RegisterInfo extends State { top: 20, bottom: 20, left: 10, right: 10), readOnly: true, )), - AppText('Nationality'), + AppText(TranslationBase.of(context).nationality), Container( margin: EdgeInsets.only(bottom: 10), child: TextFields( @@ -102,7 +117,7 @@ class _RegisterInfo extends State { top: 20, bottom: 20, left: 10, right: 10), readOnly: true, )), - AppText('Date of Birth'), + AppText(TranslationBase.of(context).dob), Container( margin: EdgeInsets.only(bottom: 10), child: TextFields( @@ -115,7 +130,72 @@ class _RegisterInfo extends State { ) : registerInfo != null && page == 2 ? Column( - children: [], + 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), + 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(() { + location = value; + }) + }, + items: locationList + .map>( + (Location value) { + return DropdownMenuItem( + value: value.value, + child: Text(value.name), + ); + }).toList()))), + AppText(TranslationBase.of(context).email), + Container( + margin: EdgeInsets.only(bottom: 10), + child: TextFields( + onChanged: (value) { + this.email = value; + }, + padding: EdgeInsets.only( + top: 20, bottom: 20, left: 10, right: 10), + )), + ], ) : SizedBox(), Expanded( @@ -127,9 +207,14 @@ class _RegisterInfo extends State { children: [ Expanded( child: DefaultButton( - TranslationBase.of(context).next, + page == 1 + ? TranslationBase.of(context).next + : TranslationBase.of(context).register, () => {nextPage()}, textColor: Colors.white, + color: this.isValid() == false + ? Colors.grey + : Colors.black, )) ], ), @@ -140,16 +225,110 @@ class _RegisterInfo extends State { } nextPage() { - setState(() { - page++; - }); + if (page == 1) { + setState(() { + page++; + }); + } else { + registerNow(); + } + } + + registerNow() { + dynamic request = getTempUserRequest(); + request = RegisterUserRequest.fromJson(request); + this.authService.registerUser(request); } - registerNow() {} getRegisterInfo() async { - registerInfo = + var data = RegisterInfoResponse.fromJson(await sharedPref.getObject(NHIC_DATA)); - print(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)); + + setState(() { + this.registerInfo = data; + + this.registerd_data = data2; + }); + } + } + + getTempUserRequest() { + return { + "Patientobject": { + "TempValue": true, + "PatientIdentificationType": 1, + "PatientIdentificationNo": registerInfo.idNumber, + "MobileNumber": registerd_data['patientMobileNumber'], + "PatientOutSA": registerd_data['zipCode'] == '966' ? '0' : '1', + "FirstName": registerInfo.firstNameEn, + "MiddleName": registerInfo.secondNameEn, + "LastName": registerInfo.lastNameEn, + "StrDateofBirth": registerInfo.dateOfBirth, + "DateofBirth": "/Date(1522098000000)/", + "Gender": registerInfo.gender, + "NationalityID": registerInfo.nationality, + "DateofBirthN": registerInfo.dateOfBirth, + "EmailAddress": email, + "SourceType": location, + "PreferredLanguage": registerd_data['languageID'], + "Marital": registerInfo.maritalStatusCode == 'U' + ? '0' + : registerInfo.maritalStatusCode == 'M' + ? '1' + : '2', + }, + "PatientIdentificationID": registerInfo.idNumber, + "PatientMobileNumber": registerd_data['PatientMobileNumber'], + }; + + // var patientObject ={}; + // var request ={}; + // patientObject['PatientIdentificationType'] = this.identificationType; + // patientObject['PatientIdentificationNo'] = this.id; + // request['PatientIdentificationID'] = this.id; + // request['PatientMobileNumber'] = this.registerInfo.MobileNumber; + // patientObject['MobileNumber'] = this.registerInfo.MobileNumber; + // patientObject['PatientOutSA'] = this.registerInfo.PatientOutSA; + // request['LogInTokenID'] = this.registerInfo.LogInTokenID; + // request['activationCode'] = this.registerInfo.activationCode; + // request['ProjectID'] = this.selectedProjectID; + // patientObject['ProjectID'] = this.selectedProjectID; + // request + // request.setBirthDate(this.dateOfBirth, this.cs.convertISODateToJsonDate(this.dateOfBirth)); + // request.setGender(this.gender); + // request.Patientobject.NationalityID = this.selectedNationalityID; + // request.Patientobject.StrDateofBirth = this.dateOfBirth; + // request.Patientobject.DateofBirthN = this.dateHijri; + // request.Patientobject.EmailAddress = this.eMail; + // request.Patientobject.SourceType = this.iSOCountryID + // request.Patientobject.PreferredLanguage = this.preferredLanguage + // request.Patientobject.Marital = this.maritalStatus; + //return request; + } + + bool isValid() { + if (location != null || + language != null || + Utils.validEmail(email) == true) { + return true; + } else { + return false; + } } } + +class Language { + final String name; + final String value; + Language({this.name, this.value}); +} + +class Location { + final String name; + final String value; + Location({this.name, this.value}); +} diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 3e0e67e0..1b9f6e22 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -722,6 +722,7 @@ class TranslationBase { String get selectAge => localizedValues['select-age'][locale.languageCode]; String get iAm => localizedValues['i-am'][locale.languageCode]; String get yearOld => localizedValues['years-old'][locale.languageCode]; + String get email => localizedValues['email'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index 33a1d072..0a7d6026 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -152,4 +152,10 @@ class Utils { static Uint8List dataFromBase64String(String base64String) { return base64Decode(base64String); } + + static validEmail(email) { + return RegExp( + r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+") + .hasMatch(email); + } } From b9b5797cbc85fbe3bee137ba6673ac663262bf59 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Thu, 5 Nov 2020 19:15:53 +0300 Subject: [PATCH 2/3] login issue fixed --- lib/pages/landing/landing_page.dart | 45 +++++++++++-------- lib/pages/login/confirm-login.dart | 2 +- .../authentication/auth_provider.dart | 2 +- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index bb3589d9..031ccdc3 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -52,7 +52,8 @@ class _LandingPageState extends State with WidgetsBindingObserver { ProjectViewModel projectProvider; ///inject the user data - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); final authService = new AuthProvider(); @@ -134,21 +135,21 @@ class _LandingPageState extends State with WidgetsBindingObserver { }); _requestIOSPermissions(); pageController = PageController(keepPage: true); - // _firebaseMessaging.setAutoInitEnabled(true); - // - // if (Platform.isIOS) { - // _firebaseMessaging.requestNotificationPermissions(); - // } - // - // _firebaseMessaging.getToken().then((String token) { - // sharedPref.setString(PUSH_TOKEN, token); - // if (token != null) { - // checkUserStatus(token); - // } - // requestPermissions(); - // }).catchError((err) { - // print(err); - // }); + _firebaseMessaging.setAutoInitEnabled(true); + + if (Platform.isIOS) { + _firebaseMessaging.requestNotificationPermissions(); + } + + _firebaseMessaging.getToken().then((String token) { + sharedPref.setString(PUSH_TOKEN, token); + if (token != null) { + checkUserStatus(token); + } + requestPermissions(); + }).catchError((err) { + print(err); + }); //_firebase Background message handler // _firebaseMessaging.configure( @@ -345,7 +346,11 @@ class _LandingPageState extends State with WidgetsBindingObserver { headline6: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), - title: Texts(getText(currentTab).toUpperCase(),bold: true,color: Colors.white,), + title: Texts( + getText(currentTab).toUpperCase(), + bold: true, + color: Colors.white, + ), leading: Builder( builder: (BuildContext context) { return IconButton( @@ -373,7 +378,11 @@ class _LandingPageState extends State with WidgetsBindingObserver { physics: NeverScrollableScrollPhysics(), controller: pageController, children: [ - HomePage(goToMyProfile: () {_changeCurrentTab(1);},), + HomePage( + goToMyProfile: () { + _changeCurrentTab(1); + }, + ), MedicalProfilePage(), BookingOptions(), Container(), diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index c06dd473..800939bb 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -523,7 +523,7 @@ class _ConfirmLogin extends State { checkIfUserAgreedBefore(CheckActivationCode result) { print(result); - if (result.isNeedUserAgreement) { + if (result.isNeedUserAgreement ==true) { //move to agreement page. } else { insertIMEI(); diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index 2142bc53..fcf1069c 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -111,7 +111,7 @@ class AuthProvider with ChangeNotifier { var imei = await sharedPref.getString(PUSH_TOKEN); // if (!request.) { - newRequest.iMEI = imei; + newRequest.iMEI =imei; //imei!=null ? imei : ''; newRequest.firstName = request.firstName + " " + request.lastName; newRequest.firstNameN = request.firstNameN + " " + request.lastNameN; newRequest.lastNameN = request.lastNameN ?? ""; From 0443a37886a5dc116ddf16806cf0d24e9aa81007 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Sat, 7 Nov 2020 18:39:23 +0300 Subject: [PATCH 3/3] register page updated --- lib/config/localized_values.dart | 1 + lib/pages/login/register-info.dart | 49 +++++++++++++++++++++--- lib/uitl/translations_delegate_base.dart | 2 + 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 8bcff719..949c0629 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -683,4 +683,5 @@ const Map> localizedValues = { "Book": {"en": "Book", "ar": "احجز"}, "AppointmentLabel": {"en": "Appointment", "ar": "موعد"}, "BloodType": {"en": "Blood Type", "ar": "فصيلة الدم"}, + "marital-status": {"en": "Marital status", "ar": "الحالة الإجتماعية"} }; diff --git a/lib/pages/login/register-info.dart b/lib/pages/login/register-info.dart index a3240665..7aa95696 100644 --- a/lib/pages/login/register-info.dart +++ b/lib/pages/login/register-info.dart @@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/models/Authentication/register_user_requet. import 'package:diplomaticquarterapp/pages/login/login-type.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; @@ -83,13 +84,29 @@ class _RegisterInfo extends State { top: 20, bottom: 20, left: 10, right: 10), readOnly: true, )), - AppText(TranslationBase.of(context).name), + AppText(TranslationBase.of(context).firstName), Container( margin: EdgeInsets.only(bottom: 10), child: TextFields( - hintText: registerInfo.firstNameEn + - ' ' + - registerInfo.lastNameEn, + hintText: 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, + 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, padding: EdgeInsets.only( top: 20, bottom: 20, left: 10, right: 10), readOnly: true, @@ -107,6 +124,15 @@ class _RegisterInfo extends State { 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), @@ -116,6 +142,15 @@ class _RegisterInfo extends State { 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, + padding: EdgeInsets.only( + top: 20, bottom: 20, left: 10, right: 10), + readOnly: true, + )), AppText(TranslationBase.of(context).dob), Container( margin: EdgeInsets.only(bottom: 10), @@ -190,6 +225,7 @@ class _RegisterInfo extends State { child: TextFields( onChanged: (value) { this.email = value; + this.isValid(); }, padding: EdgeInsets.only( top: 20, bottom: 20, left: 10, right: 10), @@ -211,7 +247,7 @@ class _RegisterInfo extends State { : TranslationBase.of(context).register, () => {nextPage()}, textColor: Colors.white, - color: this.isValid() == false + color: this.isValid() == false && page == 2 ? Colors.grey : Colors.black, )) @@ -266,7 +302,8 @@ class _RegisterInfo extends State { "MiddleName": registerInfo.secondNameEn, "LastName": registerInfo.lastNameEn, "StrDateofBirth": registerInfo.dateOfBirth, - "DateofBirth": "/Date(1522098000000)/", + "DateofBirth": + DateUtil.convertISODateToJsonDate(registerInfo.dateOfBirth), "Gender": registerInfo.gender, "NationalityID": registerInfo.nationality, "DateofBirthN": registerInfo.dateOfBirth, diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index d763ed04..551cd8ff 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -736,6 +736,8 @@ class TranslationBase { String get loginToUseService => localizedValues['loginToUseService'][locale.languageCode]; + String get maritalStatus => + localizedValues['marital-status'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate {