From 8fd318548aeab00be1093124829fe2583f70f8ef Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 6 Apr 2021 13:15:45 +0300 Subject: [PATCH] finish chief complaint design --- .../subjective/update_Chief_complaints.dart | 140 +++++++----------- .../subjective/update_medication_widget.dart | 7 +- .../subjective/update_subjective_page.dart | 46 +++++- lib/widgets/shared/TextFields.dart | 13 +- 4 files changed, 106 insertions(+), 100 deletions(-) diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_Chief_complaints.dart b/lib/widgets/patients/profile/soap_update/subjective/update_Chief_complaints.dart index ef1caeb5..fd424767 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_Chief_complaints.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_Chief_complaints.dart @@ -1,10 +1,10 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/new_text_Field.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:hexcolor/hexcolor.dart'; + +import '../custom_validation_error.dart'; class UpdateChiefComplaints extends StatelessWidget { const UpdateChiefComplaints({ @@ -13,18 +13,24 @@ class UpdateChiefComplaints extends StatelessWidget { @required this.complaintsController, @required this.illnessController, @required this.medicationController, + this.complaintsControllerError, + this.illnessControllerError, + this.medicationControllerError, }) : super(key: key); final GlobalKey formKey; final TextEditingController complaintsController; final TextEditingController illnessController; final TextEditingController medicationController; + final String complaintsControllerError; + final String illnessControllerError; + final String medicationControllerError; @override Widget build(BuildContext context) { return Form( key: formKey, - child: Column(children: [ + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 20, ), @@ -33,9 +39,14 @@ class UpdateChiefComplaints extends StatelessWidget { hintText: TranslationBase.of(context).addChiefComplaints, controller: complaintsController, maxLines: 25, - minLines: 13, + minLines: 3, ), + Container( + child: CustomValidationError( + error: complaintsControllerError, + )), + // Container( // margin: // EdgeInsets.only(left: 10, right: 10, top: 15), @@ -66,89 +77,46 @@ class UpdateChiefComplaints extends StatelessWidget { // return null; // }), // ), - SizedBox( - height: 20, - ), - - NewTextFields( - hintText: TranslationBase.of(context).historyOfPresentIllness, - controller: illnessController, - maxLines: 25, - minLines: 13, - ), - // Container( - // margin: - // EdgeInsets.only(left: 10, right: 10, top: 15), - // child: TextFields( - // hasLabelText: - // illnessController.text != '' ? true : false, - // showLabelText: true, - // hintText: TranslationBase - // .of(context) - // .historyOfPresentIllness, - // fontSize: 13.5, - // // hintColor: Colors.black, - // fontWeight: FontWeight.w600, - // maxLines: 25, - // minLines: 13, - // controller: illnessController, - // validator: (value) { - // if (value == null || value == "") - // return TranslationBase.of(context) - // .emptyMessage; - // else - // return null; - // }), - // ), - SizedBox( - height: 20, - ), - SizedBox( - height: 10, - ), - UpdateMedicationWidget( - medicationController: medicationController, - ), - SizedBox( - height: 10, - ), - // Container( - // margin: - // EdgeInsets.only(left: 10, right: 10, top: 15), - // child: TextFields( - // hasLabelText: medicationController.text != '' - // ? true - // : false, - // showLabelText: true, - // hintText: TranslationBase - // .of(context) - // .currentMedications, - // fontSize: 13.5, - // // hintColor: Colors.black, - // fontWeight: FontWeight.w600, - // maxLines: 23, - // minLines: 10, - // controller: medicationController, - // validator: (value) { - // if (value == null || value == "") - // return TranslationBase - // .of(context) - // .emptyMessage; - // else - // return null; - // }), - // ), + SizedBox( + height: 20, + ), - NewTextFields( - hintText: TranslationBase.of(context).currentMedications, - controller: medicationController, - maxLines: 23, - minLines: 10, - ), - SizedBox( - height: 10, - ), - ]), + NewTextFields( + hintText: TranslationBase + .of(context) + .historyOfPresentIllness, + controller: illnessController, + maxLines: 25, + minLines: 3, + ), + Container( + child: CustomValidationError(error: illnessControllerError,)), + SizedBox( + height: 20, + ), + SizedBox( + height: 10, + ), + UpdateMedicationWidget( + medicationController: medicationController, + ), + SizedBox( + height: 10, + ), + NewTextFields( + hintText: TranslationBase + .of(context) + .currentMedications, + controller: medicationController, + maxLines: 25, + minLines: 3, + ), + Container(child: CustomValidationError( + error: medicationControllerError,)), + SizedBox( + height: 10, + ), + ]), ); } } \ No newline at end of file diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart index f32bfe6e..68844765 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart @@ -16,6 +16,7 @@ import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dialogs/master_key_dailog.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; import '../custom_validation_error.dart'; @@ -40,17 +41,19 @@ class _UpdateMedicationWidgetState extends State { return Column( children: [ Container( - margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: TextFields( hintText: TranslationBase.of(context).addMedication, + borderColor: HexColor('#707070'), + borderWidth: 0.30, fontSize: 13.5, + borderRadius: 12, onTapTextFields: () { openMedicationList(context); }, readOnly: true, // hintColor: Colors.black, suffixIcon: EvaIcons.plusCircleOutline, - suffixIconColor: AppGlobal.appPrimaryColor, + suffixIconColor: Color(0xFF2B353E), fontWeight: FontWeight.w600, // controller: messageController, validator: (value) { diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart index 140fec54..c40ee25e 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -19,8 +19,6 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_Chief_complaints.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_history_widget.dart'; -import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; @@ -53,7 +51,9 @@ class _UpdateSubjectivePageState extends State { TextEditingController illnessController = TextEditingController(); TextEditingController complaintsController = TextEditingController(); TextEditingController medicationController = TextEditingController(); - + String complaintsControllerError = ''; + String medicationControllerError = ''; + String illnessControllerError = ''; final formKey = GlobalKey(); getHistory(SOAPViewModel model) async { @@ -235,8 +235,7 @@ class _UpdateSubjectivePageState extends State { height: 30, ), ExpandableSOAPWidget( - headerTitle: TranslationBase - .of(context) + headerTitle: TranslationBase.of(context) .chiefComplaints .toUpperCase(), onTap: () { @@ -244,7 +243,15 @@ class _UpdateSubjectivePageState extends State { isChiefExpand = !isChiefExpand; }); }, - child: UpdateChiefComplaints(formKey: formKey, complaintsController: complaintsController, illnessController: illnessController, medicationController: medicationController), + child: UpdateChiefComplaints( + formKey: formKey, + complaintsController: complaintsController, + illnessController: illnessController, + medicationController: medicationController, + complaintsControllerError: complaintsControllerError, + illnessControllerError: illnessControllerError, + medicationControllerError: medicationControllerError, + ), isExpanded: isChiefExpand, ), SizedBox( @@ -356,7 +363,9 @@ class _UpdateSubjectivePageState extends State { formKey.currentState.save(); formKey.currentState.validate(); - + complaintsControllerError = ''; + medicationControllerError = ''; + illnessControllerError = ''; if (complaintsController.text.isNotEmpty && illnessController.text.isNotEmpty && complaintsController.text.length > 25) { @@ -382,6 +391,29 @@ class _UpdateSubjectivePageState extends State { widget.changePageViewIndex(1); } else { + setState(() { + if (complaintsController.text.isEmpty) { + complaintsControllerError = TranslationBase + .of(context) + .emptyMessage; + } else if (complaintsController.text.length < 25) { + complaintsControllerError = TranslationBase + .of(context) + .chiefComplaintLength; + } + + if (illnessController.text.isEmpty) { + illnessControllerError = TranslationBase + .of(context) + .emptyMessage; + } + + if (medicationController.text.isEmpty) { + medicationControllerError = TranslationBase + .of(context) + .emptyMessage; + } + }); helpers.showErrorToast(TranslationBase .of(context) .chiefComplaintErrorMsg); diff --git a/lib/widgets/shared/TextFields.dart b/lib/widgets/shared/TextFields.dart index aab1eb61..18d8e778 100644 --- a/lib/widgets/shared/TextFields.dart +++ b/lib/widgets/shared/TextFields.dart @@ -77,7 +77,7 @@ class TextFields extends StatefulWidget { this.hasBorder = true, this.onTapTextFields, this.hasLabelText = false, - this.showLabelText = false, this.borderRadius= 8.0}) + this.showLabelText = false, this.borderRadius= 8.0, this.borderColor, this.borderWidth = 1, }) : super(key: key); final String hintText; @@ -116,8 +116,9 @@ class TextFields extends StatefulWidget { final Color fillColor; final bool hasBorder; final bool showLabelText; - + Color borderColor; final double borderRadius; + final double borderWidth; bool hasLabelText; @override @@ -202,6 +203,8 @@ class _TextFieldsState extends State { @override Widget build(BuildContext context) { + + widget.borderColor = widget.borderColor?? Colors.grey; return (AnimatedContainer( duration: Duration(milliseconds: 300), decoration: widget.bare @@ -321,7 +324,7 @@ class _TextFieldsState extends State { borderRadius: BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius)), focusedBorder: OutlineInputBorder( borderSide: widget.hasBorder - ? BorderSide(color: Colors.grey, width: 1.0) + ? BorderSide(color: widget.borderColor,width: widget.borderWidth) : BorderSide(color: Colors.transparent, width: 0), borderRadius: widget.hasBorder ? BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius) @@ -329,14 +332,14 @@ class _TextFieldsState extends State { ), disabledBorder: OutlineInputBorder( borderSide: widget.hasBorder - ? BorderSide(color: Colors.grey, width: 1.0) + ? BorderSide(color: widget.borderColor,width: widget.borderWidth) : BorderSide(color: Colors.transparent, width: 0), borderRadius: widget.hasBorder ? BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius) : BorderRadius.circular(0.0)), enabledBorder: OutlineInputBorder( borderSide: widget.hasBorder - ? BorderSide(color: Colors.grey, width: 1.0) + ? BorderSide(color: widget.borderColor,width: widget.borderWidth) : BorderSide(color: Colors.transparent, width: 0), borderRadius: widget.hasBorder ? BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius)