From 25f65802a55a45a57f61afb68e30eaed1c0e8030 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sun, 7 Nov 2021 16:55:03 +0200 Subject: [PATCH 1/3] register search page change --- lib/models/doctor/profile_req_Model.dart | 10 +- .../RegisterSearchPatientPage.dart | 143 ++++++++++-------- .../register_patient/VerifyMethodPage.dart | 82 ++++++---- .../text_fields/country_textfield_custom.dart | 77 ++++++++++ 4 files changed, 214 insertions(+), 98 deletions(-) create mode 100644 lib/widgets/shared/text_fields/country_textfield_custom.dart diff --git a/lib/models/doctor/profile_req_Model.dart b/lib/models/doctor/profile_req_Model.dart index 8f2ef985..647de385 100644 --- a/lib/models/doctor/profile_req_Model.dart +++ b/lib/models/doctor/profile_req_Model.dart @@ -24,14 +24,14 @@ class ProfileReqModel { {this.projectID, this.clinicID, this.doctorID, - this.isRegistered =true, + this.isRegistered = true, this.license, this.languageID, this.stamp = '2020-04-26T09:32:18.317Z', - this.iPAdress='11.11.11.11', - this.versionID=5.5, - this.channel=9, - this.sessionID='E2bsEeYEJo', + this.iPAdress = '11.11.11.11', + this.versionID = 6.5, + this.channel = 9, + this.sessionID = 'E2bsEeYEJo', this.tokenID, this.isLoginForDoctorApp = true}); diff --git a/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart b/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart index ee8caa90..91ee7dd9 100644 --- a/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart @@ -18,14 +18,15 @@ import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dar import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/country_textfield_custom.dart'; import 'package:flutter/material.dart'; class RegisterSearchPatientPage extends StatefulWidget { final Function changePageViewIndex; - final PatientRegistrationViewModel model; + final PatientRegistrationViewModel model; - - const RegisterSearchPatientPage({Key key, this.changePageViewIndex, this.model}) + const RegisterSearchPatientPage( + {Key key, this.changePageViewIndex, this.model}) : super(key: key); @override @@ -36,23 +37,43 @@ class RegisterSearchPatientPage extends StatefulWidget { class _RegisterSearchPatientPageState extends State { String countryError; dynamic _selectedCountry; - bool isSubmitted = false; + List countryList; + + dynamic country; - TextEditingController _phoneController = TextEditingController(text: "508079569"); + //var countryName = ["Saudi Arabia", "UAE"]; + bool isSubmitted = false; + + TextEditingController _phoneController = + TextEditingController(text: "508079569"); TextEditingController _phoneCode = TextEditingController(text: "966"); String phoneError; - TextEditingController _idController = TextEditingController(text: "1062938285"); + TextEditingController _idController = + TextEditingController(text: "1062938285"); String idError; DateTime _birthDate; String birthdateError; + @override + void initState() { + _phoneCode.text = ""; + countryList = List(); + + dynamic ksaCountry = {"id": 967, "name": "Saudi Arabia"}; + dynamic uaeCountry = {"id": 971, "name": "United Arab Emirates"}; + + countryList.add(ksaCountry); + countryList.add(uaeCountry); + } + @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; + /// TODO Elham* add transaltion return AppScaffold( @@ -77,15 +98,19 @@ class _RegisterSearchPatientPageState extends State { SizedBox( height: 10, ), - AppTextFieldCustom( - height: screenSize.height * 0.075, + CountryTextField( + elementList: countryList, + element: country, + elementError: countryError, + keyName: 'name', + keyId: 'id', + okFunction: (selectedValue) { + setState(() { + country = selectedValue; + _phoneCode.text = selectedValue['id'].toString(); + }); + }, hintText: "Country", - isTextFieldHasSuffix: true, - validationError: countryError, - dropDownText: _selectedCountry != null - ? _selectedCountry['nameEn'] - : "Saudi Arabia", - enabled: false, ), SizedBox( height: 10, @@ -102,16 +127,18 @@ class _RegisterSearchPatientPageState extends State { inputType: TextInputType.phone, controller: _phoneCode, validationError: phoneError, + enabled: false, ), ), - if(_phoneController - .text.isEmpty && - isSubmitted - ) - SizedBox(height: 35,) + if (_phoneController.text.isEmpty && isSubmitted) + SizedBox( + height: 35, + ) ], ), - SizedBox(width: 10,), + SizedBox( + width: 10, + ), Expanded( child: Container( // width: MediaQuery.of(context).size.width*0.7, @@ -120,12 +147,10 @@ class _RegisterSearchPatientPageState extends State { hintText: "Phone Number", inputType: TextInputType.phone, controller: _phoneController, - validationError: _phoneController - .text.isEmpty && - isSubmitted - ? TranslationBase.of(context) - .emptyMessage - : null, + validationError: + _phoneController.text.isEmpty && isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, ), ), ), @@ -139,11 +164,8 @@ class _RegisterSearchPatientPageState extends State { hintText: "ID Number", inputType: TextInputType.phone, controller: _idController, - validationError: _idController - .text.isEmpty && - isSubmitted - ? TranslationBase.of(context) - .emptyMessage + validationError: _idController.text.isEmpty && isSubmitted + ? TranslationBase.of(context).emptyMessage : null, ), SizedBox( @@ -165,10 +187,8 @@ class _RegisterSearchPatientPageState extends State { : null, enabled: false, isTextFieldHasSuffix: true, - validationError: _birthDate == null && - isSubmitted - ? TranslationBase.of(context) - .emptyMessage + validationError: _birthDate == null && isSubmitted + ? TranslationBase.of(context).emptyMessage : null, suffixIcon: IconButton( icon: Icon( @@ -235,42 +255,43 @@ class _RegisterSearchPatientPageState extends State { setState(() { isSubmitted = true; }); - if(isFormValid()) { + if (isFormValid()) { GifLoaderDialogUtils.showMyDialog(context); CheckPatientForRegistrationModel - checkPatientForRegistrationModel = - CheckPatientForRegistrationModel( - patientIdentificationID: - int.parse(_idController.text), - patientMobileNumber: - int.parse(_phoneController.text), - zipCode: _phoneCode.text, - isHijri: 0, - patientID: 0, - isRegister: false, - isDentalAllowedBackend: false, - patientOutSA: 0, - generalid: GENERAL_ID, - dOB: - "${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}"); + checkPatientForRegistrationModel = + CheckPatientForRegistrationModel( + patientIdentificationID: + int.parse(_idController.text), + patientMobileNumber: + int.parse(_phoneController.text), + zipCode: _phoneCode.text, + isHijri: 0, + patientID: 0, + isRegister: false, + isDentalAllowedBackend: false, + patientOutSA: 0, + generalid: GENERAL_ID, + dOB: + "${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}"); await widget.model.checkPatientForRegistration( checkPatientForRegistrationModel); GetPatientInfoRequestModel getPatientInfoRequestModel = - GetPatientInfoRequestModel( + GetPatientInfoRequestModel( //TODO Elham* this return the static to dynamic - patientIdentificationID:"1062938285", //_idController.text, + //patientIdentificationID:"1062938285", _idController.text, isHijri: 0, isDentalAllowedBackend: false, patientOutSA: 0, generalid: GENERAL_ID, sessionID: null, - dOB:"31/07/1988",//"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "dd/MM/yyyy")}" - + dOB: + "31/07/1988", //"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "dd/MM/yyyy")}" ); if (widget.model.state == ViewState.ErrorLocal) { Helpers.showErrorToast(widget.model.error); } else { - await widget.model.getPatientInfo(getPatientInfoRequestModel); + await widget.model + .getPatientInfo(getPatientInfoRequestModel); if (widget.model.state == ViewState.ErrorLocal) { Helpers.showErrorToast(widget.model.error); } else { @@ -279,7 +300,6 @@ class _RegisterSearchPatientPageState extends State { } GifLoaderDialogUtils.hideDialog(context); } - }, ), ), @@ -290,14 +310,17 @@ class _RegisterSearchPatientPageState extends State { ); } - isFormValid() { - if(_phoneController.text!=null &&_phoneController.text.isNotEmpty&& _idController.text!=null &&_idController.text.isNotEmpty &&_birthDate!=null) { + if (_phoneController.text != null && + _phoneController.text.isNotEmpty && + _idController.text != null && + _idController.text.isNotEmpty && + _birthDate != null) { return true; } return false; - } + Future _selectDate(BuildContext context, DateTime dateTime, Function(DateTime picked) updateDate) async { final DateTime picked = await showDatePicker( diff --git a/lib/screens/patients/register_patient/VerifyMethodPage.dart b/lib/screens/patients/register_patient/VerifyMethodPage.dart index 6426c382..8634e76e 100644 --- a/lib/screens/patients/register_patient/VerifyMethodPage.dart +++ b/lib/screens/patients/register_patient/VerifyMethodPage.dart @@ -105,27 +105,33 @@ class _ActivationPageState extends State { children: [ Row( children: [ - Image.asset( - "assets/images/verify-sms.png", - height: MediaQuery.of(context) - .size - .height * - 0.15, - width: MediaQuery.of(context) - .size - .width * - 0.15, + Padding( + padding: EdgeInsets.symmetric( + horizontal: 10), + child: Image.asset( + "assets/images/verify-sms.png", + height: MediaQuery.of(context) + .size + .height * + 0.15, + width: MediaQuery.of(context) + .size + .width * + 0.15, + ), ), ], ), SizedBox( height: 20, ), - AppText( - "Verify through SMS", - fontSize: 14, - color: Color(0xFF2E303A), - fontWeight: FontWeight.bold, + Center( + child: AppText( + "Verify through SMS", + fontSize: 14, + color: Color(0xFF2E303A), + fontWeight: FontWeight.bold, + ), ) ], ), @@ -155,27 +161,33 @@ class _ActivationPageState extends State { children: [ Row( children: [ - Image.asset( - "assets/images/verify-whtsapp.png", - height: MediaQuery.of(context) - .size - .height * - 0.15, - width: MediaQuery.of(context) - .size - .width * - 0.15, + Padding( + padding: EdgeInsets.symmetric( + horizontal: 10.0), + child: Image.asset( + "assets/images/verify-whtsapp.png", + height: MediaQuery.of(context) + .size + .height * + 0.15, + width: MediaQuery.of(context) + .size + .width * + 0.15, + ), ), ], ), SizedBox( height: 20, ), - AppText( - "Verify through WhatsApp", - fontSize: 14, - color: Color(0xFF2E303A), - fontWeight: FontWeight.bold, + Center( + child: AppText( + "Verify through WhatsApp", + fontSize: 14, + color: Color(0xFF2E303A), + fontWeight: FontWeight.bold, + ), ) ], ), @@ -445,11 +457,12 @@ class _ActivationPageState extends State { fontSize: 2.0, onPressed: () async { GifLoaderDialogUtils.showMyDialog(context); - await widget.model.checkActivationCode("${digit1.text}${digit2.text}${digit3.text}${digit4.text}"); + await widget.model.checkActivationCode( + "${digit1.text}${digit2.text}${digit3.text}${digit4.text}"); if (widget.model.state == ViewState.ErrorLocal) { Helpers.showErrorToast(widget.model.error); //TODO Elham* remove this - widget.changePageViewIndex(2); + //widget.changePageViewIndex(2); GifLoaderDialogUtils.hideDialog(context); } else { GifLoaderDialogUtils.hideDialog(context); @@ -473,7 +486,10 @@ class _ActivationPageState extends State { Helpers.showErrorToast(widget.model.error); GifLoaderDialogUtils.hideDialog(context); // TODO Elham* retuen the else - // } else { + setState(() { + isSendOtp = false; + }); + } else { setState(() { isSendOtp = true; }); diff --git a/lib/widgets/shared/text_fields/country_textfield_custom.dart b/lib/widgets/shared/text_fields/country_textfield_custom.dart new file mode 100644 index 00000000..baed4995 --- /dev/null +++ b/lib/widgets/shared/text_fields/country_textfield_custom.dart @@ -0,0 +1,77 @@ +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class CountryTextField extends StatefulWidget { + final dynamic element; + final String elementError; + final List elementList; + final String keyName; + final String keyId; + final String hintText; + final double width; + final Function(dynamic) okFunction; + + CountryTextField( + {Key key, + @required this.element, + @required this.elementError, + this.width, + this.elementList, + this.keyName, + this.keyId, + this.hintText, + this.okFunction}) + : super(key: key); + + @override + _CountryTextfieldState createState() => _CountryTextfieldState(); +} + +class _CountryTextfieldState extends State { + @override + Widget build(BuildContext context) { + return Container( + width: widget.width ?? null, + child: InkWell( + onTap: widget.elementList != null + ? () { + Helpers.hideKeyboard(context); + ListSelectDialog dialog = ListSelectDialog( + list: widget.elementList, + attributeName: '${widget.keyName}', + attributeValueId: widget.elementList.length == 1 + ? widget.elementList[0]['${widget.keyId}'] + : '${widget.keyId}', + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) => + widget.okFunction(selectedValue), + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: AppTextFieldCustom( + hintText: widget.hintText, + dropDownText: widget.elementList.length == 1 + ? widget.elementList[0]['${widget.keyName}'] + : widget.element != null + ? widget.element['${widget.keyName}'] + : null, + isTextFieldHasSuffix: true, + validationError: + widget.elementList.length != 1 ? widget.elementError : null, + enabled: false, + ), + ), + ); + } +} From 92d81700e17b4478be8b51ade03944be45169438 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 8 Nov 2021 12:29:57 +0200 Subject: [PATCH 2/3] adding country option to register page --- .../patients/register_patient/RegisterPatientPage.dart | 1 + .../register_patient/RegisterSearchPatientPage.dart | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/screens/patients/register_patient/RegisterPatientPage.dart b/lib/screens/patients/register_patient/RegisterPatientPage.dart index 740906ba..231ff3d1 100644 --- a/lib/screens/patients/register_patient/RegisterPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterPatientPage.dart @@ -53,6 +53,7 @@ class _RegisterPatientPageState extends State @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; + ///TODO Elham* Add Translation return BaseView( builder: (_, model, w) => AppScaffold( diff --git a/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart b/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart index 91ee7dd9..432842d3 100644 --- a/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart @@ -42,7 +42,6 @@ class _RegisterSearchPatientPageState extends State { dynamic country; - //var countryName = ["Saudi Arabia", "UAE"]; bool isSubmitted = false; TextEditingController _phoneController = @@ -255,6 +254,11 @@ class _RegisterSearchPatientPageState extends State { setState(() { isSubmitted = true; }); + if (country == null) { + countryError = TranslationBase.of(context).fieldRequired; + } else { + countryError = null; + } if (isFormValid()) { GifLoaderDialogUtils.showMyDialog(context); CheckPatientForRegistrationModel From 132d781eb525763e96522fa847e1f091b0a59d18 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 9 Nov 2021 08:45:31 +0200 Subject: [PATCH 3/3] conflect resorved --- lib/models/doctor/profile_req_Model.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/models/doctor/profile_req_Model.dart b/lib/models/doctor/profile_req_Model.dart index f1f71010..115f389d 100644 --- a/lib/models/doctor/profile_req_Model.dart +++ b/lib/models/doctor/profile_req_Model.dart @@ -24,14 +24,14 @@ class ProfileReqModel { {this.projectID, this.clinicID, this.doctorID, - this.isRegistered =true, + this.isRegistered = true, this.license, this.languageID, this.stamp = '2020-04-26T09:32:18.317Z', - this.iPAdress='11.11.11.11', + this.iPAdress = '11.11.11.11', // this.versionID=5.5, - this.channel=9, - this.sessionID='E2bsEeYEJo', + this.channel = 9, + this.sessionID = 'E2bsEeYEJo', this.tokenID, this.isLoginForDoctorApp = true});