finish confirmation page

merge-requests/879/head
Elham Rababh 4 years ago
parent 4fe53ef71e
commit ad845b882c

@ -1,4 +1,5 @@
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -8,13 +9,14 @@ class CustomEditableText extends StatefulWidget {
Key key, Key key,
@required this.controller, @required this.controller,
this.hint, this.hint,
this.isEditable = false, this.isEditable = false, this.isSubmitted,
}) : super(key: key); }) : super(key: key);
final TextEditingController controller; final TextEditingController controller;
final String hint; final String hint;
bool isEditable; bool isEditable;
final bool isSubmitted;
@override @override
_CustomEditableTextState createState() => _CustomEditableTextState(); _CustomEditableTextState createState() => _CustomEditableTextState();
@ -77,6 +79,12 @@ class _CustomEditableTextState extends State<CustomEditableText> {
hintText: widget.hint, hintText: widget.hint,
//TranslationBase.of(context).addoperationReports, //TranslationBase.of(context).addoperationReports,
controller: widget.controller, controller: widget.controller,
validationError: widget.controller
.text.isEmpty &&
widget.isSubmitted
? TranslationBase.of(context)
.emptyMessage
: null,
maxLines: 1, maxLines: 1,
minLines: 1, minLines: 1,
hasBorder: true, hasBorder: true,

@ -63,6 +63,9 @@ class _RegisterConfirmationPatientPageState
TextEditingController middleNameAr; TextEditingController middleNameAr;
TextEditingController lastNameAr; TextEditingController lastNameAr;
TextEditingController emailAddressController; TextEditingController emailAddressController;
TextEditingController langController = TextEditingController(
text: "English");
int selectedLang = 1;
@override @override
void initState() { void initState() {
@ -84,6 +87,8 @@ class _RegisterConfirmationPatientPageState
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
projectViewModel = Provider.of(context); projectViewModel = Provider.of(context);
///TODO Elham* add translation
return AppScaffold( return AppScaffold(
isShowAppBar: false, isShowAppBar: false,
backgroundColor: Color(0xFFF8F8F8), backgroundColor: Color(0xFFF8F8F8),
@ -107,36 +112,44 @@ class _RegisterConfirmationPatientPageState
children: [ children: [
CustomEditableText( CustomEditableText(
controller: firstNameN, controller: firstNameN,
isSubmitted: isSubmitted,
hint: TranslationBase.of(context).firstName), hint: TranslationBase.of(context).firstName),
SizedBox( SizedBox(
height: 4, height: 4,
), ),
CustomEditableText( CustomEditableText(
controller: middleNameN, controller: middleNameN,
isEditable: middleNameN.text.isEmpty,
isSubmitted: isSubmitted,
hint: TranslationBase.of(context).middleName), hint: TranslationBase.of(context).middleName),
SizedBox( SizedBox(
height: 4, height: 4,
), ),
CustomEditableText( CustomEditableText(
controller: lastNameN, controller: lastNameN,
isSubmitted: isSubmitted,
hint: TranslationBase.of(context).lastName), hint: TranslationBase.of(context).lastName),
SizedBox( SizedBox(
height: 20, height: 20,
), ),
CustomEditableText( CustomEditableText(
controller: firstNameAr, controller: firstNameAr,
isSubmitted: isSubmitted,
hint: "First Name Arabic"), hint: "First Name Arabic"),
SizedBox( SizedBox(
height: 4, height: 4,
), ),
CustomEditableText( CustomEditableText(
controller: middleNameAr, controller: middleNameAr,
isEditable: middleNameN.text.isEmpty,
isSubmitted: isSubmitted,
hint: "Middle Name Arabic"), hint: "Middle Name Arabic"),
SizedBox( SizedBox(
height: 4, height: 4,
), ),
CustomEditableText( CustomEditableText(
controller: lastNameAr, controller: lastNameAr,
isSubmitted: isSubmitted,
hint: "Last Name Arabic"), hint: "Last Name Arabic"),
SizedBox( SizedBox(
height: 20, height: 20,
@ -294,6 +307,7 @@ class _RegisterConfirmationPatientPageState
onClick: () { onClick: () {
openLangList(context); openLangList(context);
}, },
controller: langController,
hintText: TranslationBase.of(context).lanEnglish, hintText: TranslationBase.of(context).lanEnglish,
maxLines: 1, maxLines: 1,
minLines: 1, minLines: 1,
@ -315,6 +329,11 @@ class _RegisterConfirmationPatientPageState
maxLines: 1, maxLines: 1,
minLines: 1, minLines: 1,
hasBorder: true, hasBorder: true,
validationError:
emailAddressController.text.isEmpty &&
isSubmitted
? TranslationBase.of(context).emptyMessage
: null,
), ),
SizedBox( SizedBox(
height: 400, height: 400,
@ -367,16 +386,21 @@ class _RegisterConfirmationPatientPageState
fontColor: Colors.white, fontColor: Colors.white,
fontSize: 2.0, fontSize: 2.0,
onPressed: () async { onPressed: () async {
print(widget.model setState(() {
.getPatientInfoResponseModel.dateOfBirth); isSubmitted = true;
});
if (isFormValid()) {
print(
widget.model.getPatientInfoResponseModel.dateOfBirth);
var dateFormat = DateFormat('MM/dd/yyyy').parse(widget.model var dateFormat = DateFormat('MM/dd/yyyy').parse(
.getPatientInfoResponseModel.dateOfBirth); widget.model.getPatientInfoResponseModel.dateOfBirth);
String wellFormat = "${dateFormat.day}\/${dateFormat.month}\/${dateFormat.year}"; String wellFormat =
print (dateFormat.toUtc().toString()); "${dateFormat.day}\/${dateFormat.month}\/${dateFormat.year}";
HijriCalendar hijriDate = HijriCalendar.fromDate(new DateTime(dateFormat.year, dateFormat.month, dateFormat.day)); print(dateFormat.toUtc().toString());
HijriCalendar hijriDate = HijriCalendar.fromDate(
new DateTime(dateFormat.year, dateFormat.month,
dateFormat.day));
// return ; // return ;
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
@ -397,7 +421,10 @@ class _RegisterConfirmationPatientPageState
middleName: middleNameAr.text, middleName: middleNameAr.text,
middleNameN: middleNameN.text, middleNameN: middleNameN.text,
strDateofBirth: dateFormat.toUtc().toString(), strDateofBirth: dateFormat.toUtc().toString(),
dateofBirth: AppDateUtils.convertToServerFormat(widget.model.getPatientInfoResponseModel.dateOfBirth, 'MM/dd/yyyy'), dateofBirth: AppDateUtils.convertToServerFormat(
widget.model.getPatientInfoResponseModel
.dateOfBirth,
'MM/dd/yyyy'),
dateofBirthN: '$hijriDate', dateofBirthN: '$hijriDate',
gender: (widget.model.getPatientInfoResponseModel.gender == "M") gender: (widget.model.getPatientInfoResponseModel.gender == "M")
? 1 ? 1
@ -409,10 +436,10 @@ class _RegisterConfirmationPatientPageState
.getPatientInfoResponseModel .getPatientInfoResponseModel
.nationalityCode, .nationalityCode,
//todo Elham* change static value to dynamic //todo Elham* change static value to dynamic
preferredLanguage: "1", preferredLanguage: selectedLang.toString(),
marital: "0", marital: "0",
eHealthIDField: widget eHealthIDField: widget.model
.model.getPatientInfoResponseModel.healthId, .getPatientInfoResponseModel.healthId,
emailAddress: emailAddressController.text, emailAddress: emailAddressController.text,
mobileNumber: widget mobileNumber: widget
.model .model
@ -423,23 +450,29 @@ class _RegisterConfirmationPatientPageState
isDentalAllowedBackend: false, isDentalAllowedBackend: false,
patientOutSA: 0, patientOutSA: 0,
sessionID: null, sessionID: null,
patientMobileNumber: patientMobileNumber: widget
widget.model.checkPatientForRegistrationModel.patientMobileNumber.toString(), .model
healthId: widget.model.getPatientInfoResponseModel.healthId, .checkPatientForRegistrationModel
.patientMobileNumber
.toString(),
healthId:
widget.model.getPatientInfoResponseModel.healthId,
generalid: GENERAL_ID, generalid: GENERAL_ID,
patientIdentificationID: widget.model.checkPatientForRegistrationModel.patientIdentificationID.toString(), patientIdentificationID: widget.model.checkPatientForRegistrationModel.patientIdentificationID.toString(),
dOB:wellFormat, dOB: wellFormat,
zipCode: widget.model.checkPatientForRegistrationModel.zipCode); zipCode: widget.model.checkPatientForRegistrationModel.zipCode);
await widget.model await widget.model
.registrationPatient(patientRegistrationModel); .registrationPatient(patientRegistrationModel);
if (widget.model.state == ViewState.ErrorLocal) { if (widget.model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(widget.model.error); Helpers.showErrorToast(widget.model.error);
} else { } else {
DrAppToastMsg.showSuccesToast("Patient added Successfully"); DrAppToastMsg.showSuccesToast(
"Patient added Successfully");
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
}
}, },
), ),
), ),
@ -598,14 +631,16 @@ class _RegisterConfirmationPatientPageState
height: 10, height: 10,
), ),
InkWell( InkWell(
onTap: () {}, onTap: () {
setSelectedLang(1);
},
child: Row( child: Row(
children: [ children: [
Radio( Radio(
value: 1, value: 1,
groupValue: 1, groupValue: selectedLang,
onChanged: (value) { onChanged: (value) {
setState(() {}); setSelectedLang(value);
}, },
activeColor: Colors.red, activeColor: Colors.red,
), ),
@ -619,14 +654,17 @@ class _RegisterConfirmationPatientPageState
), ),
), ),
InkWell( InkWell(
onTap: () {}, onTap: () {
setSelectedLang(2);
},
child: Row( child: Row(
children: [ children: [
Radio( Radio(
value: 1, value: 2,
groupValue: 1, groupValue: selectedLang,
onChanged: (value) { onChanged: (value) {
setState(() {}); setSelectedLang(value);
}, },
activeColor: Colors.red, activeColor: Colors.red,
), ),
@ -644,4 +682,23 @@ class _RegisterConfirmationPatientPageState
); );
}); });
} }
setSelectedLang(lang){
setState(() {
selectedLang = lang;
langController.text = lang==1?"English": "العربيه";
});
Navigator.of(context).pop();
}
bool isFormValid() {
if (middleNameAr.text != null &&
middleNameAr.text.isNotEmpty &&
middleNameN.text != null &&
middleNameN.text.isNotEmpty &&
emailAddressController.text != null &&
emailAddressController.text.isNotEmpty) {
return true;
}
return false;
}
} }

@ -52,7 +52,7 @@ class _RegisterPatientPageState extends State<RegisterPatientPage>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size; final screenSize = MediaQuery.of(context).size;
///TODO Elham* Add Translation
return BaseView<PatientRegistrationViewModel>( return BaseView<PatientRegistrationViewModel>(
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,
@ -72,6 +72,7 @@ class _RegisterPatientPageState extends State<RegisterPatientPage>
SizedBox( SizedBox(
height: 10, height: 10,
), ),
//TODO Elham* Fix overflow
PageStepperWidget( PageStepperWidget(
stepsCount: 3, stepsCount: 3,
currentStepIndex: _currentIndex + 1, currentStepIndex: _currentIndex + 1,

@ -36,6 +36,8 @@ class RegisterSearchPatientPage extends StatefulWidget {
class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> { class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
String countryError; String countryError;
dynamic _selectedCountry; dynamic _selectedCountry;
bool isSubmitted = false;
TextEditingController _phoneController = TextEditingController(); TextEditingController _phoneController = TextEditingController();
TextEditingController _phoneCode = TextEditingController(text: "966"); TextEditingController _phoneCode = TextEditingController(text: "966");
@ -51,6 +53,7 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size; final screenSize = MediaQuery.of(context).size;
/// TODO Elham* add transaltion
return AppScaffold( return AppScaffold(
baseViewModel: widget.model, baseViewModel: widget.model,
@ -83,39 +86,16 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
? _selectedCountry['nameEn'] ? _selectedCountry['nameEn']
: "Saudi Arabia", : "Saudi Arabia",
enabled: false, enabled: false,
/*onClick: widget.model.dietTypesList != null && widget.model.dietTypesList.length > 0
? () {
openListDialogField('nameEn', 'id', widget.model.dietTypesList, (selectedValue) {
setState(() {
_selectedCountry = selectedValue;
});
});
}
: () async {
GifLoaderDialogUtils.showMyDialog(context);
await model
.getDietTypes(patient.patientId)
.then((_) => GifLoaderDialogUtils.hideDialog(context));
if (widget.model.state == ViewState.Idle && widget.model.dietTypesList.length > 0) {
openListDialogField('nameEn', 'id', widget.model.dietTypesList, (selectedValue) {
setState(() {
_selectedCountry = selectedValue;
});
});
} else if (widget.model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(widget.model.error);
} else {
DrAppToastMsg.showErrorToast("Empty List");
}
},*/
), ),
SizedBox( SizedBox(
height: 10, height: 10,
), ),
Row( Row(
children: [
Column(
children: [ children: [
Container( Container(
width: MediaQuery.of(context).size.width * 0.3, width: MediaQuery.of(context).size.width * 0.28,
child: AppTextFieldCustom( child: AppTextFieldCustom(
height: screenSize.height * 0.075, height: screenSize.height * 0.075,
hintText: "Code", hintText: "Code",
@ -124,6 +104,14 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
validationError: phoneError, validationError: phoneError,
), ),
), ),
if(_phoneController
.text.isEmpty &&
isSubmitted
)
SizedBox(height: 35,)
],
),
SizedBox(width: 10,),
Expanded( Expanded(
child: Container( child: Container(
// width: MediaQuery.of(context).size.width*0.7, // width: MediaQuery.of(context).size.width*0.7,
@ -132,7 +120,12 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
hintText: "Phone Number", hintText: "Phone Number",
inputType: TextInputType.phone, inputType: TextInputType.phone,
controller: _phoneController, controller: _phoneController,
validationError: phoneError, validationError: _phoneController
.text.isEmpty &&
isSubmitted
? TranslationBase.of(context)
.emptyMessage
: null,
), ),
), ),
), ),
@ -146,7 +139,12 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
hintText: "ID Number", hintText: "ID Number",
inputType: TextInputType.phone, inputType: TextInputType.phone,
controller: _idController, controller: _idController,
validationError: idError, validationError: _idController
.text.isEmpty &&
isSubmitted
? TranslationBase.of(context)
.emptyMessage
: null,
), ),
SizedBox( SizedBox(
height: 12, height: 12,
@ -167,7 +165,11 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
: null, : null,
enabled: false, enabled: false,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: true,
validationError: birthdateError, validationError: _birthDate == null &&
isSubmitted
? TranslationBase.of(context)
.emptyMessage
: null,
suffixIcon: IconButton( suffixIcon: IconButton(
icon: Icon( icon: Icon(
Icons.calendar_today, Icons.calendar_today,
@ -230,6 +232,10 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
fontColor: Colors.white, fontColor: Colors.white,
fontSize: 2.0, fontSize: 2.0,
onPressed: () async { onPressed: () async {
setState(() {
isSubmitted = true;
});
if(isFormValid()) {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
CheckPatientForRegistrationModel CheckPatientForRegistrationModel
checkPatientForRegistrationModel = checkPatientForRegistrationModel =
@ -261,14 +267,19 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
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) { if (widget.model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(widget.model.error); Helpers.showErrorToast(widget.model.error);
} else { } else {
widget.changePageViewIndex(1); widget.changePageViewIndex(1);
} }
}
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
}
}, },
), ),
), ),
@ -279,6 +290,14 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
); );
} }
isFormValid() {
if(_phoneController.text!=null &&_phoneController.text.isNotEmpty&& _idController.text!=null &&_idController.text.isNotEmpty) {
return true;
}
return false;
}
Future _selectDate(BuildContext context, DateTime dateTime, Future _selectDate(BuildContext context, DateTime dateTime,
Function(DateTime picked) updateDate) async { Function(DateTime picked) updateDate) async {
final DateTime picked = await showDatePicker( final DateTime picked = await showDatePicker(

Loading…
Cancel
Save