From 7505a6b6b0b0813fd115ffd91fdd7629b91556e7 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 31 Jan 2021 17:32:22 +0200 Subject: [PATCH] =?UTF-8?q?fix=20=C2=A0allergy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subjective/update_allergies_widget.dart | 130 ++++++++++++------ .../soap_update/update_soap_index.dart | 2 +- 2 files changed, 90 insertions(+), 42 deletions(-) diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart index 09297ab3..afd14809 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart @@ -31,9 +31,6 @@ class UpdateAllergiesWidget extends StatefulWidget { } class _UpdateAllergiesWidgetState extends State { - - TextEditingController remarkController = TextEditingController(); - @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); @@ -237,6 +234,9 @@ class _AddAllergiesState extends State { MasterKeyModel _selectedAllergySeverity; MasterKeyModel _selectedAllergy; TextEditingController remarkController = TextEditingController(); + TextEditingController severityController = TextEditingController(); + TextEditingController allergyController = TextEditingController(); + GlobalKey key = new GlobalKey>(); bool isFormSubmitted = false; @@ -244,23 +244,27 @@ class _AddAllergiesState extends State { String hintText, String selectedText, bool isDropDown, {IconData icon}) { return InputDecoration( + contentPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderSide: BorderSide(color: Colors.grey, width: 1.0), borderRadius: BorderRadius.circular(8), ), enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderSide: BorderSide(color: Colors.grey, width: 1.0), borderRadius: BorderRadius.circular(8), ), disabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderSide: BorderSide(color: Colors.grey, width: 1.0), borderRadius: BorderRadius.circular(8), ), hintText: selectedText != null ? selectedText : hintText, suffixIcon: isDropDown ? Icon(icon ?? Icons.arrow_drop_down) : null, hintStyle: TextStyle( - fontSize: 14, - color: Colors.grey.shade600, + fontSize: 10, + color: Theme + .of(context) + .hintColor, + fontWeight: FontWeight.w700 ), ); } @@ -314,6 +318,7 @@ class _AddAllergiesState extends State { ? () { setState(() { _selectedAllergy = null; + allergyController.text = null; }); } : null, @@ -326,7 +331,15 @@ class _AddAllergiesState extends State { ? _selectedAllergy.nameEn : null, true, icon: EvaIcons.search), itemSubmitted: (item) => - setState(() => _selectedAllergy = item), + setState(() { + _selectedAllergy = item; + allergyController.text = + projectViewModel.isArabic + ? _selectedAllergy + .nameAr + : _selectedAllergy + .nameEn; + }), key: key, suggestions: model.allergiesList, itemBuilder: (context, suggestion) => @@ -334,27 +347,44 @@ class _AddAllergiesState extends State { child: Texts( projectViewModel.isArabic ? suggestion .nameAr : suggestion.nameEn), - padding: EdgeInsets.all(8.0)), + padding: EdgeInsets.all(2.0)), itemSorter: (a, b) => 1, itemFilter: (suggestion, input) => suggestion.nameAr.toLowerCase().startsWith( input.toLowerCase()) || suggestion.nameEn.toLowerCase() .startsWith(input.toLowerCase()), - ) : TextField( - decoration: textFieldSelectorDecoration( - TranslationBase - .of(context) - .selectAllergy, - _selectedAllergy != null - ? projectViewModel.isArabic - ? _selectedAllergy.nameAr - : _selectedAllergy.nameEn - : null, - true, - icon: EvaIcons.search), - enabled: false, - ), + ) : + TextFields( + onTapTextFields: model.allergiesList != null + ? () { + setState(() { + _selectedAllergy = null; + allergyController.text = null; + }); + } + : null, + hasLabelText: allergyController.text != + '' ? true : false, + showLabelText: true, + hintText: TranslationBase + .of(context) + .selectAllergy, + fontSize: 13.5, + readOnly: true, + fontWeight: FontWeight.w600, + maxLines: 2, + minLines: 1, + controller: allergyController, + suffixIcon: EvaIcons.search, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }) ), ), if(isFormSubmitted && _selectedAllergy == null) @@ -362,10 +392,9 @@ class _AddAllergiesState extends State { SizedBox( height: 10, ), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: model.allergySeverityList != null + TextFields( + onTapTextFields: model + .allergySeverityList != null ? () { MasterKeyDailog dialog = MasterKeyDailog( list: model.allergySeverityList, @@ -376,6 +405,13 @@ class _AddAllergiesState extends State { setState(() { _selectedAllergySeverity = selectedValue; + + severityController.text = + projectViewModel.isArabic + ? _selectedAllergySeverity + .nameAr + : _selectedAllergySeverity + .nameEn; }); }, ); @@ -388,21 +424,33 @@ class _AddAllergiesState extends State { ); } : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase - .of(context) - .selectSeverity, - _selectedAllergySeverity != null - ? projectViewModel.isArabic?_selectedAllergySeverity.nameAr:_selectedAllergySeverity.nameEn - : null, - true), - enabled: false, - ), - ), + hasLabelText: severityController.text != + '' ? true : false, + showLabelText: true, + hintText: TranslationBase + .of(context) + .selectSeverity, + fontSize: 13.5, + readOnly: true, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + maxLines: 2, + minLines: 1, + controller: severityController, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }), SizedBox( + height: 5, ), - if(isFormSubmitted && _selectedAllergySeverity == null) + if(isFormSubmitted && + _selectedAllergySeverity == null) CustomValidationError(), + SizedBox( height: 10, ), diff --git a/lib/widgets/patients/profile/soap_update/update_soap_index.dart b/lib/widgets/patients/profile/soap_update/update_soap_index.dart index 61e5a4b4..5c646121 100644 --- a/lib/widgets/patients/profile/soap_update/update_soap_index.dart +++ b/lib/widgets/patients/profile/soap_update/update_soap_index.dart @@ -37,7 +37,7 @@ class _UpdateSoapIndexState extends State GetPatientProgressNoteResModel patientProgressNote = GetPatientProgressNoteResModel(); changePageViewIndex(pageIndex) { - changeLoadingState(true); + if (pageIndex != _currentIndex) changeLoadingState(true); _controller.jumpToPage(pageIndex); }