diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 7c13c84a..944c0bd2 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -757,7 +757,6 @@ const Map localizedValues = { "permissions": {"en": "Permission", "ar": "الصلاحيات"}, "camera-permission": {"en": "Camera", "ar": "الكاميرا"}, "location-permission": {"en": "Location", "ar": "تحديد المواقع"}, - "needPrescription": {"en": "This product requires a prescription", "ar": " هذا المنتج يتطلب وصفة طبية"}, "outOfStockMsg": {"en": "You have added product which is out of stock now, Please remove that!", "ar": "لقد قمت بإضافة المنتج الذي نفذ من المخزون الآن. يرجى إزالة ذلك"}, "accessibility": {"en": "Accessibility Mode", "ar": "وضع امكانية الوصول"}, @@ -1532,6 +1531,7 @@ const Map localizedValues = { "OtherInfo": {"en": "Other Info", "ar": "معلومات اخرى"}, "inPrgress": {"en": "In Progress", "ar": "في تقدم"}, "locked": {"en": "Locked", "ar": "مقفل"}, + "personalInfo": {"en": "Personal Information", "ar": "معلومات شخصية"}, "cmcTitle": {"en": "Comprehensive", "ar": "خدمة"}, "cmcSubtitle": {"en": "Medical Checkup", "ar": "الفحص الشامل"}, "emergencyTitle": {"en": "Emergency", "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/ChildVaccines/new/child_vaccine_page.dart b/lib/pages/ChildVaccines/new/child_vaccine_page.dart index 2563fa63..2a876cfa 100644 --- a/lib/pages/ChildVaccines/new/child_vaccine_page.dart +++ b/lib/pages/ChildVaccines/new/child_vaccine_page.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/core/model/childvaccines/delete_baby_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/child_vaccines_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -10,6 +11,7 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; import '../add_newchild_page.dart'; import '../vaccinationtable_page.dart'; @@ -31,274 +33,175 @@ class _ChildPageState extends State with SingleTickerProviderS var checkedValue = true; return BaseView( - onModelReady: (model) => model.getNewUserOrders(), - builder: (_, model, widget) => AppScaffold( - isShowAppBar: true, - appBarTitle: TranslationBase.of(context).vaccination, - baseViewModel: model, - showNewAppBarTitle: true, - showNewAppBar: true, - body: Column( - children: [ - Expanded( - child: ListView.separated( - itemBuilder: (context, index) { - return InkWell( - onTap: () { - Navigator.push( - context, - FadePage( - page: VaccinationTablePage(model.babyInformationModelList[index]), - ), - ); - }, - child: Container( - margin: EdgeInsets.only(left: 0, right: 0, bottom: 20), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.all(Radius.circular(12)), - color: Colors.white, - gradient: LinearGradient( - colors: model.babyInformationModelList[index].gender == 1 - ? [ - Color(0xFFFDA4B0), - Color(0xFFFBC8CC), - ] - : [ - Color(0xFF6EA8FF), - Color(0xFF7AB8FD), - ], - begin: Alignment.centerLeft, - end: Alignment.centerRight, - ), - ), - padding: EdgeInsets.all(12), - //double.infinity, + onModelReady: (model) => model.getNewUserOrders(), + builder: (_, model, widget) => AppScaffold( + isShowAppBar: true, + appBarTitle: TranslationBase.of(context).vaccination, + baseViewModel: model, + showNewAppBarTitle: true, + showNewAppBar: true, + body: Column( + children: [ + Expanded( + child: ListView.separated( + itemBuilder: (context, index) { + Color selectedColor = model.babyInformationModelList[index].gender == 1 ? Color(0xFF5A282E) : Colors.white; + return InkWell( + onTap: () { + Navigator.push( + context, + FadePage( + page: VaccinationTablePage(model.babyInformationModelList[index]), + ), + ); + }, + child: Container( + margin: EdgeInsets.only(left: 16, right: 16), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + borderRadius: BorderRadius.all(Radius.circular(12)), + color: Colors.white, + gradient: LinearGradient( + colors: model.babyInformationModelList[index].gender == 1 + ? [ + Color(0xFFFDA4B0), + Color(0xFFFBC8CC), + ] + : [ + Color(0xFF6EA8FF), + Color(0xFF7AB8FD), + ], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + ), + ), + padding: EdgeInsets.all(12), + //double.infinity, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts(model.babyInformationModelList[index].babyName.trim()), - Row(children: [ - IconButton( - icon: Image.asset(model.babyInformationModelList[index].gender == 1 ? 'assets/images/new-design/male.png' : 'assets/images/new-design/female.png'), - tooltip: '', - onPressed: () { - setState(() { - // _volume += 10; - // launch("tel://" +model.FindusHospitalModelList[index].phoneNumber); - }); - }, + Text( + model.babyInformationModelList[index].babyName.trim(), + style: TextStyle( + fontSize: 14, + letterSpacing: -0.46, + fontWeight: FontWeight.bold, + color: selectedColor, ), - Texts(model.babyInformationModelList[index].genderDescription), - IconButton( - icon: Icon( - Icons.remove_red_eye, - color: Colors.red, - ), - tooltip: '', - onPressed: () { - Navigator.push( - context, - FadePage( - page: VaccinationTablePage(model.babyInformationModelList[index]), - ), - ); - }, - ) - ]), - Row(children: [ - Texts(TranslationBase.of(context).dob), - ]), - Row(children: [ - IconButton( - icon: new Image.asset('assets/images/new-design/calender-secondary.png'), - tooltip: '', - onPressed: () { - setState(() {}); - }, + ), + Text( + model.babyInformationModelList[index].gender == 1 ? TranslationBase.of(context).female : TranslationBase.of(context).male, + style: TextStyle( + fontSize: 11, + color: selectedColor, ), - Texts(DateUtil.yearMonthDay(model.babyInformationModelList[index].dOB)), - ]), - Row(children: [ - IconButton( - icon: new Image.asset('assets/images/new-design/garbage.png'), - tooltip: '', - onPressed: () async { - //===================== - await model.deleteBabyOrders(newChild: deleteBaby); + ), + Row( + children: [ + Text( + TranslationBase.of(context).dob, + style: TextStyle( + fontSize: 11, + color: selectedColor, + ), + ), + Text(DateUtil.yearMonthDay(model.babyInformationModelList[index].dOB), + style: TextStyle( + fontSize: 11, + color: selectedColor, + )), + ], + ), + mHeight(20), + ], + ), + ), + InkWell( + onTap: () async { + await model.deleteBabyOrders(newChild: deleteBaby); - deleteBaby.babyID = model.babyInformationModelList[index].babyID; + deleteBaby.babyID = model.babyInformationModelList[index].babyID; - await model.deleteBabyOrders(newChild: deleteBaby); - if (model.isDeleted) { - AppToast.showSuccessToast(message: TranslationBase.of(context).recordDeleted); - Navigator.pop(context, model.isDeleted); - } else { - //TODO handling error - } - }, + await model.deleteBabyOrders(newChild: deleteBaby); + if (model.isDeleted) { + AppToast.showSuccessToast(message: TranslationBase.of(context).recordDeleted); + Navigator.pop(context, model.isDeleted); + } else { + //TODO handling error + } + }, + child: Container( + decoration: containerRadius(Colors.black.withOpacity(0.2), 2000), + padding: EdgeInsets.only(left: 12, right: 12, top: 8, bottom: 8), + child: Row( + children: [ + Image.asset( + 'assets/images/new-design/garbage.png', + width: 16, + color: selectedColor, ), - Texts(TranslationBase.of(context).deleteView), - ]), - SizedBox( - height: 12, - ), - ], + mWidth(8), + Text( + TranslationBase.of(context).deleteView, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + letterSpacing: -0.33, + color: selectedColor, + ), + ), + ], + ), ), ), - ); - }, - separatorBuilder: (BuildContext context, int index) { - return mHeight(12); - }, - itemCount: model.babyInformationModelList.length, + ], + ), ), - ), - // Container( - // height: height * 0.85, - // child: SingleChildScrollView( - // child: Container( - // margin: EdgeInsets.only(left: 8, right: 8, top: 16), - // child: GridView.count( - // crossAxisCount: 2, - // childAspectRatio: (itemWidth / (itemHeight + 0)), - // crossAxisSpacing: 10, - // mainAxisSpacing: 10, - // controller: ScrollController(keepScrollOffset: true), - // shrinkWrap: true, - // padding: const EdgeInsets.all(4.0), - // children: [ - // ...List.generate( - // model.babyInformationModelList.length, - // (index) => InkWell( - // onTap: () { - // Navigator.push( - // context, - // FadePage( - // page: VaccinationTablePage(model.babyInformationModelList[index]), - // ), - // ); - // }, - // child: Container( - // margin: EdgeInsets.only(left: 0, right: 0, bottom: 20), - // decoration: BoxDecoration( - // shape: BoxShape.rectangle, - // border: Border.all(color: Colors.white, width: 0.5), - // borderRadius: BorderRadius.all(Radius.circular(5)), - // color: Colors.white, - // ), - // padding: EdgeInsets.all(12), - // //double.infinity, - // child: Column( - // children: [ - // Row(children: [ - // Texts(TranslationBase.of(context).childName), - // ]), - // Row(children: [ - // Texts(model.babyInformationModelList[index].babyName.trim()), - // ]), - // Row(children: [ - // IconButton( - // icon: Image.asset(model.babyInformationModelList[index].gender == 1 ? 'assets/images/new-design/male.png' : 'assets/images/new-design/female.png'), - // tooltip: '', - // onPressed: () { - // setState(() { - // // _volume += 10; - // // launch("tel://" +model.FindusHospitalModelList[index].phoneNumber); - // }); - // }, - // ), - // Texts(model.babyInformationModelList[index].genderDescription), - // IconButton( - // icon: Icon( - // Icons.remove_red_eye, - // color: Colors.red, - // ), - // tooltip: '', - // onPressed: () { - // Navigator.push( - // context, - // FadePage( - // page: VaccinationTablePage(model.babyInformationModelList[index]), - // ), - // ); - // }, - // ) - // ]), - // Row(children: [ - // Texts(TranslationBase.of(context).dob), - // ]), - // Row(children: [ - // IconButton( - // icon: new Image.asset('assets/images/new-design/calender-secondary.png'), - // tooltip: '', - // onPressed: () { - // setState(() {}); - // }, - // ), - // Texts(DateUtil.yearMonthDay(model.babyInformationModelList[index].dOB)), - // ]), - // Row(children: [ - // IconButton( - // icon: new Image.asset('assets/images/new-design/garbage.png'), - // tooltip: '', - // onPressed: () async { - // //===================== - // await model.deleteBabyOrders(newChild: deleteBaby); - // - // deleteBaby.babyID = model.babyInformationModelList[index].babyID; - // - // await model.deleteBabyOrders(newChild: deleteBaby); - // if (model.isDeleted) { - // AppToast.showSuccessToast(message: TranslationBase.of(context).recordDeleted); - // Navigator.pop(context, model.isDeleted); - // } else { - // //TODO handling error - // } - // }, - // ), - // Texts(TranslationBase.of(context).deleteView), - // ]), - // SizedBox( - // height: 12, - // ), - // ], - // ), - // ), - // ), - // ) - // ], - // ))), - // ), - ], + ); + }, + separatorBuilder: (BuildContext context, int index) { + return mHeight(12); + }, + itemCount: model.babyInformationModelList.length, ), - bottomSheet: Container( - height: height * 0.15, - width: double.infinity, - padding: EdgeInsets.all(16), - child: SecondaryButton( - textColor: Colors.white, - color: checkedValue == false - ? Colors.white24 - : Color.fromRGBO( - 63, - 72, - 74, - 1, - ), - label: TranslationBase.of(context).addNewChild, - // - onTap: () { - Navigator.push( - context, - FadePage( - page: AddNewChildPage(), + ), + Container( + width: double.infinity, + padding: EdgeInsets.all(16), + color: Colors.white, + child: SecondaryButton( + textColor: Colors.white, + color: checkedValue + ? CustomColors.accentColor + : Color.fromRGBO( + 63, + 72, + 74, + 1, ), - ).then((value) { - if (value) model.getNewUserOrders(); - }); - }, - ), + label: TranslationBase.of(context).addNewChild, + // + onTap: () { + Navigator.push( + context, + FadePage( + page: AddNewChildPage(), + ), + ).then((value) { + if (value) model.getNewUserOrders(); + }); + }, ), - )); + ), + ], + ), + ), + ); } } diff --git a/lib/pages/ChildVaccines/vaccinationtable_page.dart b/lib/pages/ChildVaccines/vaccinationtable_page.dart index a7ba1b71..45a63414 100644 --- a/lib/pages/ChildVaccines/vaccinationtable_page.dart +++ b/lib/pages/ChildVaccines/vaccinationtable_page.dart @@ -1,16 +1,21 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/vaccination_table_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.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/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; +import 'package:provider/provider.dart'; import 'dialogs/SelectGenderDialog.dart'; @@ -23,6 +28,7 @@ class VaccinationTablePage extends StatelessWidget { Widget build(BuildContext context) { var size = MediaQuery.of(context).size; final double height = (size.height - kToolbarHeight - 60); + ProjectViewModel projectViewModel = Provider.of(context); var checkedValue; return BaseView( @@ -31,147 +37,164 @@ class VaccinationTablePage extends StatelessWidget { isShowAppBar: true, baseViewModel: model, appBarTitle: TranslationBase.of(context).vaccination, + showNewAppBar: true, + showNewAppBarTitle: true, + backgroundColor: CustomColors.appBackgroudGrey2Color, body: Container( - height: height * 0.85, - child: SingleChildScrollView( - child: Container( - margin: EdgeInsets.only(left: 16, right: 16, top: 16), - child: Column( - children: [ - Row( - children: [ - Expanded( - child: Texts(TranslationBase.of(context).childName), - ), - Expanded( - child: Texts(TranslationBase.of(context).dob), - ), - ], - ), - SizedBox( - height: 10, - ), - Row( - children: [ - Expanded( - child: Texts(babyInfo.babyName), - ), - Expanded( - child: Texts(DateUtil.getFormattedDate( - babyInfo.dOB, "MMM dd,yyyy")), - ), - ], - ), - SizedBox( - height: 10, - ), - Divider( - color: Colors.black, - ), - Row( - children: [ - Text(TranslationBase.of(context).visit), - SizedBox( - width: 25, - ), - Expanded( - child: Text(TranslationBase.of(context).description)), - Text(TranslationBase.of(context).dueDate), - ], - ), - ...List.generate( - model.creteVaccinationTableModelList.length, - (index) => Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - // border: Border.all(color: Colors.white, width: 0.5), - borderRadius: BorderRadius.all(Radius.circular(5)), - // color: Colors.white, - ), + height: double.infinity, + child: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + margin: EdgeInsets.only(left: 16, right: 16, top: 16), + child: Column( + children: [ + Container( + decoration: containerRadius(Colors.white, 12), padding: EdgeInsets.all(12), - width: double.infinity, child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ + Text( + babyInfo.babyName, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + letterSpacing: -0.64, + ), + ), + mHeight(8), Row( children: [ - Text(model - .creteVaccinationTableModelList[index] - .visit), - SizedBox( - width: 10, + Text( + TranslationBase.of(context).gender + " :", + style: TextStyle( + fontSize: 10, + fontWeight: FontWeight.w600, + letterSpacing: -0.4, + color: CustomColors.textColor, + ), ), - Expanded( - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Html( - // data:"
BCG
HEPATITIS B
"//model.creteVaccinationTableModelList[index].vaccinesDescription - data: model - .creteVaccinationTableModelList[ - index] - .vaccinesDescription, - ), - ], + Text( + babyInfo.gender == 1 ? TranslationBase.of(context).female : TranslationBase.of(context).male, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.4, + color: CustomColors.black, ), ), - Text(model - .creteVaccinationTableModelList[index] - .givenAt), ], ), - Divider( - color: Colors.black, + Row( + children: [ + Text( + TranslationBase.of(context).dateOfBirth + " :", + style: TextStyle( + fontSize: 10, + fontWeight: FontWeight.w600, + letterSpacing: -0.4, + color: CustomColors.textColor, + ), + ), + Text( + DateUtil.getFormattedDate(babyInfo.dOB, "MMM dd,yyyy"), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.4, + color: CustomColors.black, + ), + ), + ], ), ], - ))) - ], - ), - ), - ), - ), - bottomSheet: Container( - height: height * 0.15, - width: double.infinity, - padding: EdgeInsets.all(12), - child: SecondaryButton( - textColor: Colors.white, - color: checkedValue == false - ? Colors.white24 - : Color.fromRGBO( - 63, - 72, - 74, - 1, + ), + ), + mHeight(12), + Container( + decoration: containerRadius(Colors.white, 12), + padding: EdgeInsets.all(12), + child: Table( + columnWidths: { + 0: FlexColumnWidth(1.8), + 1: FlexColumnWidth(1.8), + 2: FlexColumnWidth(1.8), + }, + children: fullData(context, model, projectViewModel), + ), + ), + ], ), - label: TranslationBase.of(context).sendEmail, - // - onTap: () { - //SelectGenderDialog(); -//=============== - showDialog( - context: context, - child: SelectGenderDialog( - okFunction: () async { - await model.getCreateVaccinationTable(babyInfo, true); - if (model.state == ViewState.Idle) { - AppToast.showSuccessToast( - message: TranslationBase.of(context) - .emailSentSuccessfully); - } else { - AppToast.showErrorToast( - message: TranslationBase.of(context) - .EmailSentError); - } - }, ), - ); - //========= - }), + ), + ), + Container( + width: double.infinity, + padding: EdgeInsets.all(12), + color: Colors.white, + child: SecondaryButton( + textColor: Colors.white, + color: CustomColors.accentColor, + label: TranslationBase.of(context).sendEmail, + // + onTap: () { + //SelectGenderDialog(); +//=============== + showDialog( + context: context, + child: SelectGenderDialog( + okFunction: () async { + await model.getCreateVaccinationTable(babyInfo, true); + if (model.state == ViewState.Idle) { + AppToast.showSuccessToast(message: TranslationBase.of(context).emailSentSuccessfully); + } else { + AppToast.showErrorToast(message: TranslationBase.of(context).EmailSentError); + } + }, + ), + ); + //========= + }, + ), + ), + ], + ), ), ), ); } + + List fullData(BuildContext context, VaccinationTableViewModel model, ProjectViewModel projectViewModel) { + List tableRow = []; + tableRow.add( + TableRow( + children: [ + Utils.tableColumnTitle(TranslationBase.of(context).visit), + Utils.tableColumnTitle(TranslationBase.of(context).description), + Utils.tableColumnTitle(TranslationBase.of(context).dueDate), + ], + ), + ); + model.creteVaccinationTableModelList.forEach( + (diabtec) { + tableRow.add( + TableRow( + children: [ + Utils.tableColumnValue(diabtec.visit, isCapitable: false, mProjectViewModel: projectViewModel), + // Utils.tableColumnValue(diabtec.vaccinesDescription, isCapitable: false, mProjectViewModel: projectViewModel), + Html( + // data:"
BCG
HEPATITIS B
"//model.creteVaccinationTableModelList[index].vaccinesDescription + data: diabtec.vaccinesDescription, + ), + Utils.tableColumnValue(diabtec.givenAt, isCapitable: false, mProjectViewModel: projectViewModel), + ], + ), + ); + }, + ); + return tableRow; + } } diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index 58453550..837e58ef 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,33 @@ 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 { + request.dob = ""; + request.healthId = ""; + request.isHijri = 0; + await this.authService.sendActivationCode(request).then((result) { + GifLoaderDialogUtils.hideDialog(context); + if (result != null && result['isSMSSent'] == true) { + this.startSMSService(type); + } + }).catchError((r) { + GifLoaderDialogUtils.hideDialog(context); + }); + } } var tempType; @@ -472,6 +498,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 +550,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 +671,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 628886db..38e180e2 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'; @@ -107,9 +107,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( @@ -277,7 +274,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: () => {}); 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 8d414886..f7def7c8 100644 --- a/lib/pages/login/register.dart +++ b/lib/pages/login/register.dart @@ -14,16 +14,18 @@ import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/alert_dialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; -import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -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: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 +38,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 +51,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 +62,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,64 +116,159 @@ 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), - ), - elevation: 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, + ))) + : 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, + )))))), ]) ], ), ), - 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])) - ], - ), - ], - )) ]), - ))); + )), + 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); @@ -182,7 +278,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); } @@ -207,7 +303,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; }); @@ -266,11 +366,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) => { @@ -279,16 +379,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 aaf92cc7..d36f9e88 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2421,6 +2421,8 @@ class TranslationBase { String get locked => localizedValues["locked"][locale.languageCode]; + String get personalInfo => localizedValues['personalInfo'][locale.languageCode]; + String get onlinePayment => localizedValues["onlinePayment"][locale.languageCode]; String get onlinePaymentSubtitle => localizedValues["onlinePaymentSubtitle"][locale.languageCode];