From 3e7bf817f3a4ca021646249b3f21d65efe24b90a Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 13 Apr 2021 16:13:15 +0300 Subject: [PATCH 1/3] refactor code in subjective --- .../soap_update/subjective/PriorityBar.dart | 2 +- .../subjective/allergies/add_allergies.dart | 203 ++++++++ .../update_allergies_widget.dart | 246 +--------- .../subjective/bottom_sheet_title.dart | 61 +++ .../history/add_history_dialog.dart | 193 ++++++++ .../history/update_history_widget.dart | 223 +++++++++ .../subjective/update_history_widget.dart | 444 ------------------ .../subjective/update_medication_widget.dart | 46 +- .../subjective/update_subjective_page.dart | 4 +- 9 files changed, 689 insertions(+), 733 deletions(-) create mode 100644 lib/widgets/patients/profile/soap_update/subjective/allergies/add_allergies.dart rename lib/widgets/patients/profile/soap_update/subjective/{ => allergies}/update_allergies_widget.dart (51%) create mode 100644 lib/widgets/patients/profile/soap_update/subjective/bottom_sheet_title.dart create mode 100644 lib/widgets/patients/profile/soap_update/subjective/history/add_history_dialog.dart create mode 100644 lib/widgets/patients/profile/soap_update/subjective/history/update_history_widget.dart delete mode 100644 lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart diff --git a/lib/widgets/patients/profile/soap_update/subjective/PriorityBar.dart b/lib/widgets/patients/profile/soap_update/subjective/PriorityBar.dart index 5858c08d..0bc1080a 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/PriorityBar.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/PriorityBar.dart @@ -66,7 +66,7 @@ class _PriorityBarState extends State { ? _prioritiesAr[index] : item, style: TextStyle( - fontSize: 15, + fontSize: 14, color: Colors.black, //Colors.black, fontWeight: FontWeight.bold, ), diff --git a/lib/widgets/patients/profile/soap_update/subjective/allergies/add_allergies.dart b/lib/widgets/patients/profile/soap_update/subjective/allergies/add_allergies.dart new file mode 100644 index 00000000..3ee67799 --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/subjective/allergies/add_allergies.dart @@ -0,0 +1,203 @@ +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; +import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_allergies_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../bottom_sheet_title.dart'; + +class AddAllergies extends StatefulWidget { + final Function addAllergiesFun; + final List myAllergiesList; + + const AddAllergies({Key key, this.addAllergiesFun, this.myAllergiesList}) + : super(key: key); + + @override + _AddAllergiesState createState() => _AddAllergiesState(); +} + +class _AddAllergiesState extends State { + List allergiesList; + List allergySeverityList; + MasterKeyModel _selectedAllergySeverity; + MasterKeyModel _selectedAllergy; + TextEditingController remarkController = TextEditingController(); + TextEditingController severityController = TextEditingController(); + TextEditingController allergyController = TextEditingController(); + List myAllergiesListLocal; + + @override + initState() { + super.initState(); + myAllergiesListLocal = [...widget.myAllergiesList]; + } + + GlobalKey key = new GlobalKey>(); + bool isFormSubmitted = false; + + InputDecoration textFieldSelectorDecoration( + String hintText, String selectedText, bool isDropDown, + {IconData icon}) { + return InputDecoration( + contentPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.grey, width: 1.0), + borderRadius: BorderRadius.circular(8), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.grey, width: 1.0), + borderRadius: BorderRadius.circular(8), + ), + disabledBorder: OutlineInputBorder( + 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: 10, + color: Theme.of(context).hintColor, + fontWeight: FontWeight.w700), + ); + } + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + final screenSize = MediaQuery.of(context).size; + return FractionallySizedBox( + heightFactor: 1, + child: BaseView( + onModelReady: (model) async { + if (model.allergiesList.length == 0) { + await model.getMasterLookup(MasterKeysService.Allergies); + } + if (model.allergySeverityList.length == 0) { + await model.getMasterLookup(MasterKeysService.AllergySeverity); + } + }, + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: false, + body: Center( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BottomSheetTitle( + title: TranslationBase.of(context).addAllergies, + ), + SizedBox( + height: 10, + ), + SizedBox( + height: 16, + ), + Expanded( + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Center( + child: NetworkBaseView( + baseViewModel: model, + child: MasterKeyCheckboxSearchAllergiesWidget( + model: model, + masterList: model.allergiesList, + removeAllergy: (master) { + setState(() { + removeAllergyFromLocalList(master); + }); + }, + addAllergy: + (MySelectedAllergy mySelectedAllergy) { + AddAllergyLocally(mySelectedAllergy); + }, + addSelectedAllergy: () => widget + .addAllergiesFun(myAllergiesListLocal), + isServiceSelected: (master) => + isServiceSelected(master), + getServiceSelectedAllergy: (master) => + getSelectedAllergy(master), + ), + ), + ), + ), + ), + ), + ]), + ), + )), + ), + ); + } + + isServiceSelected(MasterKeyModel masterKey) { + Iterable allergy = myAllergiesListLocal.where( + (element) => + masterKey.id == element.selectedAllergy.id && + masterKey.typeId == element.selectedAllergy.typeId && + element.isChecked); + if (allergy.length > 0) { + return true; + } + return false; + } + + removeAllergyFromLocalList(MasterKeyModel masterKey) { + myAllergiesListLocal + .removeWhere((element) => element.selectedAllergy.id == masterKey.id); + } + + MySelectedAllergy getSelectedAllergy(MasterKeyModel masterKey) { + Iterable allergy = myAllergiesListLocal.where( + (element) => + masterKey.id == element.selectedAllergy.id && + masterKey.typeId == element.selectedAllergy.typeId && + element.isChecked); + if (allergy.length > 0) { + return allergy.first; + } + return null; + } + + AddAllergyLocally(MySelectedAllergy mySelectedAllergy) { + if (mySelectedAllergy.selectedAllergy == null) { + helpers.showErrorToast(TranslationBase.of(context).requiredMsg); + } else { + setState(() { + List allergy = + // ignore: missing_return + myAllergiesListLocal + .where((element) => + mySelectedAllergy.selectedAllergy.id == + element.selectedAllergy.id) + .toList(); + + if (allergy.isEmpty) { + myAllergiesListLocal.add(mySelectedAllergy); + // Navigator.of(context).pop(); + } else { + allergy.first.selectedAllergy = mySelectedAllergy.selectedAllergy; + allergy.first.selectedAllergySeverity = + mySelectedAllergy.selectedAllergySeverity; + allergy.first.remark = mySelectedAllergy.remark; + allergy.first.isChecked = mySelectedAllergy.isChecked; + // Navigator.of(context).pop(); + + // helpers.showErrorToast(TranslationBase + // .of(context) + // .itemExist); + } + }); + } + } +} diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart similarity index 51% rename from lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart rename to lib/widgets/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart index 2a25861a..65cd1d63 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart @@ -20,6 +20,8 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; +import 'add_allergies.dart'; + class UpdateAllergiesWidget extends StatefulWidget { List myAllergiesList; @@ -257,250 +259,6 @@ class _UpdateAllergiesWidgetState extends State { } -class AddAllergies extends StatefulWidget { - final Function addAllergiesFun; - final List myAllergiesList; - - const AddAllergies({Key key, this.addAllergiesFun, this.myAllergiesList}) : super(key: key); - - @override - _AddAllergiesState createState() => _AddAllergiesState(); -} - -class _AddAllergiesState extends State { - List allergiesList; - List allergySeverityList; - MasterKeyModel _selectedAllergySeverity; - MasterKeyModel _selectedAllergy; - TextEditingController remarkController = TextEditingController(); - TextEditingController severityController = TextEditingController(); - TextEditingController allergyController = TextEditingController(); - List myAllergiesListLocal; - - @override - initState(){ - super.initState(); - myAllergiesListLocal = [...widget.myAllergiesList]; - } - GlobalKey key = new GlobalKey>(); - bool isFormSubmitted = false; - - InputDecoration textFieldSelectorDecoration( - String hintText, String selectedText, bool isDropDown, - {IconData icon}) { - return InputDecoration( - contentPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.grey, width: 1.0), - borderRadius: BorderRadius.circular(8), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.grey, width: 1.0), - borderRadius: BorderRadius.circular(8), - ), - disabledBorder: OutlineInputBorder( - 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: 10, - color: Theme - .of(context) - .hintColor, - fontWeight: FontWeight.w700 - ), - ); - } - - @override - Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); - final screenSize = MediaQuery - .of(context) - .size; - return FractionallySizedBox( - heightFactor: 1, - child: BaseView( - onModelReady: (model) async { - if (model.allergiesList.length == 0) { - await model.getMasterLookup(MasterKeysService.Allergies); - } - if (model.allergySeverityList.length == 0) { - await model.getMasterLookup(MasterKeysService.AllergySeverity); - } - }, - builder: (_, model, w) => - AppScaffold( - baseViewModel: model, - isShowAppBar: false, - body: Center( - child: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - - Container( - padding: EdgeInsets.only( - left: 0, right: 5, bottom: 5, top: 5), - decoration: BoxDecoration( - color: Colors.white, - ), - height: 115, - child: Container( - padding: EdgeInsets.only( - left: 10, right: 10), - margin: EdgeInsets.only(top: 40), - child: Column( - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - RichText( - text: TextSpan( - style: TextStyle( - fontSize:20, - color: Colors.black), - children: [ - new TextSpan( - text: TranslationBase.of(context). - addAllergies, - style: TextStyle( - color: Color(0xFF2B353E), - fontWeight: FontWeight.bold, - fontFamily: 'Poppins', - fontSize: 20)), - ], - ), - ), - InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Icon(FontAwesomeIcons.times, - size: 30, - color: Color(0xFF2B353E))) - ], - ), - ], - ), - ), - ), - SizedBox( - height: 10, - ), - SizedBox( - height: 16, - ), - Expanded( - child: Center( - child: FractionallySizedBox( - widthFactor: 0.9, - child: Center( - child: NetworkBaseView( - baseViewModel: model, - child: MasterKeyCheckboxSearchAllergiesWidget( - model: model, - masterList: model.allergiesList, - removeAllergy: (master) { - setState(() { - removeAllergyFromLocalList(master); - }); - }, - addAllergy: (MySelectedAllergy mySelectedAllergy){ - AddAllergyLocally(mySelectedAllergy); - }, - addSelectedAllergy: ()=> - widget.addAllergiesFun(myAllergiesListLocal) - , - isServiceSelected: (master) =>isServiceSelected(master), - getServiceSelectedAllergy: (master)=>getSelectedAllergy(master), - ), - ), - ), - ), - ), - ), - ] - - ), - ), - ) - - ), - ), - ); - } - - isServiceSelected(MasterKeyModel masterKey) { - Iterable allergy = - myAllergiesListLocal.where((element) => - masterKey.id == element.selectedAllergy.id && - masterKey.typeId == element.selectedAllergy.typeId && - element.isChecked); - if (allergy.length > 0) { - return true; - } - return false; - } - - removeAllergyFromLocalList(MasterKeyModel masterKey) { - myAllergiesListLocal.removeWhere((element) => - element.selectedAllergy.id == masterKey.id); - } - - MySelectedAllergy getSelectedAllergy(MasterKeyModel masterKey) { - Iterable allergy = - myAllergiesListLocal.where((element) => - masterKey.id == element.selectedAllergy.id && - masterKey.typeId == element.selectedAllergy.typeId && - element.isChecked); - if (allergy.length > 0) { - return allergy.first; - } - return null; - } - - AddAllergyLocally(MySelectedAllergy mySelectedAllergy) { - if ( - mySelectedAllergy.selectedAllergy == null) { - helpers.showErrorToast(TranslationBase - .of(context) - .requiredMsg); - - } else { - setState(() { - List allergy = - // ignore: missing_return - myAllergiesListLocal - .where((element) => - mySelectedAllergy.selectedAllergy.id == - element.selectedAllergy.id) - .toList(); - - if (allergy.isEmpty) { - myAllergiesListLocal.add(mySelectedAllergy); - // Navigator.of(context).pop(); - } else { - allergy.first.selectedAllergy = - mySelectedAllergy.selectedAllergy; - allergy.first.selectedAllergySeverity = - mySelectedAllergy.selectedAllergySeverity; - allergy.first.remark = mySelectedAllergy.remark; - allergy.first.isChecked = mySelectedAllergy.isChecked; - // Navigator.of(context).pop(); - - // helpers.showErrorToast(TranslationBase - // .of(context) - // .itemExist); - } - }); - }} - -} - diff --git a/lib/widgets/patients/profile/soap_update/subjective/bottom_sheet_title.dart b/lib/widgets/patients/profile/soap_update/subjective/bottom_sheet_title.dart new file mode 100644 index 00000000..a6c59c86 --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/subjective/bottom_sheet_title.dart @@ -0,0 +1,61 @@ +import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class BottomSheetTitle extends StatelessWidget { + const BottomSheetTitle({ + Key key, this.title, + }) : super(key: key); + + final String title; + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.only( + left: 0, right: 5, bottom: 5, top: 5), + decoration: BoxDecoration( + color: Colors.white, + ), + height: 115, + child: Container( + padding: EdgeInsets.only( + left: 10, right: 10), + margin: EdgeInsets.only(top: 60), + child: Column( + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + RichText( + text: TextSpan( + style: TextStyle( + fontSize:20, + color: Colors.black), + children: [ + new TextSpan( + + text: title, + style: TextStyle( + color: Color(0xFF2B353E), + fontWeight: FontWeight.bold, + fontFamily: 'Poppins', + fontSize: 20)), + ], + ), + ), + InkWell( + onTap: () { + Navigator.pop(context); + }, + child: Icon(DoctorApp.close_1, + size:20, + color: Color(0xFF2B353E))) + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/widgets/patients/profile/soap_update/subjective/history/add_history_dialog.dart b/lib/widgets/patients/profile/soap_update/subjective/history/add_history_dialog.dart new file mode 100644 index 00000000..d66f35fb --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/subjective/history/add_history_dialog.dart @@ -0,0 +1,193 @@ +import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_history.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:flutter/material.dart'; + +import '../PriorityBar.dart'; +import '../bottom_sheet_title.dart'; + +class AddHistoryDialog extends StatefulWidget { + final Function changePageViewIndex; + final PageController controller; + final List myHistoryList; + final Function addSelectedHistories; + final Function (MasterKeyModel) removeHistory; + + const AddHistoryDialog( + {Key key, this.changePageViewIndex, this.controller, this.myHistoryList, this.addSelectedHistories, this.removeHistory}) + : super(key: key); + + @override + _AddHistoryDialogState createState() => _AddHistoryDialogState(); +} + +class _AddHistoryDialogState extends State { + @override + Widget build(BuildContext context) { + return FractionallySizedBox( + heightFactor: 1, + child: BaseView( + onModelReady: (model) async { + if (model.historyFamilyList.length == 0) { + await model.getMasterLookup(MasterKeysService.HistoryFamily); + } + + if (model.historySurgicalList.length == 0) { + await model.getMasterLookup(MasterKeysService.HistorySurgical); + await model.getMasterLookup(MasterKeysService.HistorySports); + } + + if (model.historyMedicalList.length == 0) { + await model.getMasterLookup(MasterKeysService.HistoryMedical); + } + }, + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: false, + body: Center( + child: Container( + child: Column( + children: [ + BottomSheetTitle(title:TranslationBase.of(context).addHistory), + SizedBox( + height: 10, + ), + PriorityBar(onTap: (activePriority) async { + widget.changePageViewIndex(activePriority); + }), + SizedBox( + height: 20, + ), + Expanded( + child: FractionallySizedBox( + widthFactor: 0.9, + child: PageView( + physics: NeverScrollableScrollPhysics(), + controller: widget.controller, + onPageChanged: (index) { + setState(() { + // currentIndex = index; + }); + }, + scrollDirection: Axis.horizontal, + children: [ + NetworkBaseView( + baseViewModel: model, + child: MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.historyFamilyList, + removeHistory: (history){ + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history){ + setState(() { + createAndAddHistory( + history); + }); + }, + addSelectedHistories: (){ + widget.addSelectedHistories(); + }, + isServiceSelected: (master) =>isServiceSelected(master), + ), + ), + NetworkBaseView( + baseViewModel: model, + child: MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.mergeHistorySurgicalWithHistorySportList, + removeHistory: (history){ + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history){ + setState(() { + createAndAddHistory( + history); + }); + }, + addSelectedHistories: (){ + widget.addSelectedHistories(); + }, + isServiceSelected: (master) =>isServiceSelected(master), + ), + ), + NetworkBaseView( + baseViewModel: model, + child: MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.historyMedicalList, + removeHistory: (history){ + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history){ + setState(() { + createAndAddHistory( + history); + }); + }, + addSelectedHistories: (){ + widget.addSelectedHistories(); + }, + isServiceSelected: (master) =>isServiceSelected(master), + ), + ), + ], + ), + ), + ), + ], + )), + ), + ), + )); + } + + createAndAddHistory(MasterKeyModel history) { + List myhistory = widget.myHistoryList.where((element) => + history.id == + element.selectedHistory.id && + history.typeId == + element.selectedHistory.typeId + ).toList(); + + if (myhistory.isEmpty) { + setState(() { + MySelectedHistory mySelectedHistory = MySelectedHistory( + remark: history.remarks ?? "", + selectedHistory: history, + isChecked: true); + widget.myHistoryList.add(mySelectedHistory); + }); + } else { + myhistory.first.isChecked = true; + } + } + + isServiceSelected(MasterKeyModel masterKey) { + Iterable history = + widget + .myHistoryList + .where((element) => + masterKey.id == element.selectedHistory.id && + masterKey.typeId == element.selectedHistory.typeId && + element.isChecked); + if (history.length > 0) { + return true; + } + return false; + } + +} + diff --git a/lib/widgets/patients/profile/soap_update/subjective/history/update_history_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/history/update_history_widget.dart new file mode 100644 index 00000000..873c01d2 --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/subjective/history/update_history_widget.dart @@ -0,0 +1,223 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_history.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:provider/provider.dart'; + +import '../PriorityBar.dart'; +import '../bottom_sheet_title.dart'; +import 'add_history_dialog.dart'; + +class UpdateHistoryWidget extends StatefulWidget { + final List myHistoryList; + + const UpdateHistoryWidget({Key key, this.myHistoryList}) : super(key: key); + + @override + _UpdateHistoryWidgetState createState() => _UpdateHistoryWidgetState(); +} + +class _UpdateHistoryWidgetState extends State + with TickerProviderStateMixin { + PageController _controller; + int _currentIndex = 0; + + changePageViewIndex(pageIndex) { + _controller.jumpToPage(pageIndex); + } + + @override + void initState() { + _controller = new PageController(); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return Column( + children: [ + InkWell( + onTap: () { + openHistoryList(context); + }, + child: Container( + padding: EdgeInsets.symmetric( + vertical: 8, horizontal: 8.0), + margin: + EdgeInsets.symmetric(vertical: 8), + decoration: BoxDecoration( + border: Border.all( + color: Colors.grey.shade400, + width: 0.5), + borderRadius: BorderRadius.all( + Radius.circular(8), + ), + color: Colors.white, + ), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + "${TranslationBase.of(context).addHistory}", + fontSize: SizeConfig + .textMultiplier * + 1.8, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + AppText( + "${TranslationBase.of(context).searchHere}", + fontSize: SizeConfig + .textMultiplier * + 1.8, + color: Colors.grey.shade700, + fontWeight: FontWeight.bold, + ), + ], + )), + Icon( + Icons.add_box_rounded, + size: 25, + ) + ], + ), + ), + ), + SizedBox( + height: 20, + ), + Container( + margin: + EdgeInsets.only(left: 15, right: 15, top: 15), + child: Column( + children: widget.myHistoryList.map((myHistory) { + return Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + child: Texts( + projectViewModel.isArabic + ? myHistory.selectedHistory.nameAr + : myHistory.selectedHistory.nameEn, + fontSize: 15, + textDecoration: myHistory.isChecked + ? null + : TextDecoration.lineThrough, + // bold: true, + color: Colors.black), + width: MediaQuery + .of(context) + .size + .width * 0.5, + ), + if (myHistory.isChecked) + InkWell( + child: Row( + children: [ + Container( + child: Texts( + TranslationBase + .of(context) + .remove, + fontSize: 15, + variant: "bodyText", + textDecoration: myHistory.isChecked + ? null + : TextDecoration.lineThrough, + // bold: true, + color: HexColor("#B8382C"),), + // width: MediaQuery.of(context).size.width * 0.3, + ), + Icon( + FontAwesomeIcons.times, + color: HexColor("#B8382C"), + size: 17, + ), + ], + ), + onTap: () => removeHistory(myHistory.selectedHistory), + ) + ], + ), + SizedBox( + height: 20, + ), + ], + ); + }).toList(), + ), + ) + ], + ); + } + + removeHistory(MasterKeyModel historyKey) { + List history = + // ignore: missing_return + widget.myHistoryList.where((element) => + historyKey.id == + element.selectedHistory.id && + historyKey.typeId == + element.selectedHistory.typeId + ).toList(); + + + if (history.length > 0) + setState(() { + history[0].isChecked = false; + }); + } + + openHistoryList(BuildContext context) { + showModalBottomSheet( + backgroundColor: Colors.white, + isDismissible: false, + isScrollControlled: true, + context: context, + builder: (context) { + return FractionallySizedBox( + heightFactor: 1, + child: AddHistoryDialog( + changePageViewIndex: changePageViewIndex, + controller: _controller, + myHistoryList: widget.myHistoryList, + addSelectedHistories: () { + setState(() { + Navigator.of(context).pop(); + }); + }, + removeHistory: (masterKey) => removeHistory(masterKey), + ), + ); + }); + } +} + + + diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart deleted file mode 100644 index aba4af07..00000000 --- a/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart +++ /dev/null @@ -1,444 +0,0 @@ -import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; -import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; -import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; -import 'package:doctor_app_flutter/models/SOAP/my_selected_history.dart'; -import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/shared/Text.dart'; -import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; -import 'package:eva_icons_flutter/eva_icons_flutter.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:hexcolor/hexcolor.dart'; -import 'package:provider/provider.dart'; - -import 'PriorityBar.dart'; - -class UpdateHistoryWidget extends StatefulWidget { - final List myHistoryList; - - const UpdateHistoryWidget({Key key, this.myHistoryList}) : super(key: key); - - @override - _UpdateHistoryWidgetState createState() => _UpdateHistoryWidgetState(); -} - -class _UpdateHistoryWidgetState extends State - with TickerProviderStateMixin { - PageController _controller; - int _currentIndex = 0; - - changePageViewIndex(pageIndex) { - _controller.jumpToPage(pageIndex); - } - - @override - void initState() { - _controller = new PageController(); - - super.initState(); - } - - @override - Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); - return Column( - children: [ - InkWell( - onTap: () { - openHistoryList(context); - }, - child: Container( - padding: EdgeInsets.symmetric( - vertical: 8, horizontal: 8.0), - margin: - EdgeInsets.symmetric(vertical: 8), - decoration: BoxDecoration( - border: Border.all( - color: Colors.grey.shade400, - width: 0.5), - borderRadius: BorderRadius.all( - Radius.circular(8), - ), - color: Colors.white, - ), - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Expanded( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - "${TranslationBase.of(context).addHistory}", - fontSize: SizeConfig - .textMultiplier * - 1.8, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - AppText( - "${TranslationBase.of(context).searchHere}", - fontSize: SizeConfig - .textMultiplier * - 1.8, - color: Colors.grey.shade700, - fontWeight: FontWeight.bold, - ), - ], - )), - Icon( - Icons.add_box_rounded, - size: 25, - ) - ], - ), - ), - ), - SizedBox( - height: 20, - ), - Container( - margin: - EdgeInsets.only(left: 15, right: 15, top: 15), - child: Column( - children: widget.myHistoryList.map((myHistory) { - return Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Texts( - projectViewModel.isArabic - ? myHistory.selectedHistory.nameAr - : myHistory.selectedHistory.nameEn, - fontSize: 15, - textDecoration: myHistory.isChecked - ? null - : TextDecoration.lineThrough, - // bold: true, - color: Colors.black), - width: MediaQuery - .of(context) - .size - .width * 0.5, - ), - if (myHistory.isChecked) - InkWell( - child: Row( - children: [ - Container( - child: Texts( - TranslationBase - .of(context) - .remove, - fontSize: 15, - variant: "bodyText", - textDecoration: myHistory.isChecked - ? null - : TextDecoration.lineThrough, - // bold: true, - color: HexColor("#B8382C"),), - // width: MediaQuery.of(context).size.width * 0.3, - ), - Icon( - FontAwesomeIcons.times, - color: HexColor("#B8382C"), - size: 17, - ), - ], - ), - onTap: () => removeHistory(myHistory.selectedHistory), - ) - ], - ), - SizedBox( - height: 20, - ), - ], - ); - }).toList(), - ), - ) - ], - ); - } - - removeHistory(MasterKeyModel historyKey) { - List history = - // ignore: missing_return - widget.myHistoryList.where((element) => - historyKey.id == - element.selectedHistory.id && - historyKey.typeId == - element.selectedHistory.typeId - ).toList(); - - - if (history.length > 0) - setState(() { - history[0].isChecked = false; - }); - } - - openHistoryList(BuildContext context) { - showModalBottomSheet( - backgroundColor: Colors.white, - isDismissible: false, - isScrollControlled: true, - context: context, - builder: (context) { - return FractionallySizedBox( - heightFactor: 1, - child: AddHistoryDialog( - changePageViewIndex: changePageViewIndex, - controller: _controller, - myHistoryList: widget.myHistoryList, - addSelectedHistories: () { - setState(() { - Navigator.of(context).pop(); - }); - }, - removeHistory: (masterKey) => removeHistory(masterKey), - ), - ); - }); - } -} - - - -class AddHistoryDialog extends StatefulWidget { - final Function changePageViewIndex; - final PageController controller; - final List myHistoryList; - final Function addSelectedHistories; - final Function (MasterKeyModel) removeHistory; - - const AddHistoryDialog( - {Key key, this.changePageViewIndex, this.controller, this.myHistoryList, this.addSelectedHistories, this.removeHistory}) - : super(key: key); - - @override - _AddHistoryDialogState createState() => _AddHistoryDialogState(); -} - -class _AddHistoryDialogState extends State { - @override - Widget build(BuildContext context) { - return FractionallySizedBox( - heightFactor: 1, - child: BaseView( - onModelReady: (model) async { - if (model.historyFamilyList.length == 0) { - await model.getMasterLookup(MasterKeysService.HistoryFamily); - } - - if (model.historySurgicalList.length == 0) { - await model.getMasterLookup(MasterKeysService.HistorySurgical); - await model.getMasterLookup(MasterKeysService.HistorySports); - } - - if (model.historyMedicalList.length == 0) { - await model.getMasterLookup(MasterKeysService.HistoryMedical); - } - }, - builder: (_, model, w) => AppScaffold( - baseViewModel: model, - isShowAppBar: false, - body: Center( - child: Container( - child: Column( - children: [ - Container( - padding: EdgeInsets.only( - left: 0, right: 5, bottom: 5, top: 5), - decoration: BoxDecoration( - color: Colors.white, - ), - height: 115, - child: Container( - padding: EdgeInsets.only( - left: 10, right: 10), - margin: EdgeInsets.only(top: 40), - child: Column( - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - RichText( - text: TextSpan( - style: TextStyle( - fontSize:20, - color: Colors.black), - children: [ - new TextSpan( - text: TranslationBase.of(context).addHistory, - style: TextStyle( - color: Color(0xFF2B353E), - fontWeight: FontWeight.bold, - fontFamily: 'Poppins', - fontSize: 20)), - ], - ), - ), - InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Icon(FontAwesomeIcons.times, - size: 30, - color: Color(0xFF2B353E))) - ], - ), - ], - ), - ), - ), - SizedBox( - height: 10, - ), - PriorityBar(onTap: (activePriority) async { - widget.changePageViewIndex(activePriority); - }), - SizedBox( - height: 20, - ), - Expanded( - child: FractionallySizedBox( - widthFactor: 0.9, - child: PageView( - physics: NeverScrollableScrollPhysics(), - controller: widget.controller, - onPageChanged: (index) { - setState(() { - // currentIndex = index; - }); - }, - scrollDirection: Axis.horizontal, - children: [ - NetworkBaseView( - baseViewModel: model, - child: MasterKeyCheckboxSearchWidget( - model: model, - masterList: model.historyFamilyList, - removeHistory: (history){ - setState(() { - widget.removeHistory(history); - }); - }, - addHistory: (history){ - setState(() { - createAndAddHistory( - history); - }); - }, - addSelectedHistories: (){ - widget.addSelectedHistories(); - }, - isServiceSelected: (master) =>isServiceSelected(master), - ), - ), - NetworkBaseView( - baseViewModel: model, - child: MasterKeyCheckboxSearchWidget( - model: model, - masterList: model.mergeHistorySurgicalWithHistorySportList, - removeHistory: (history){ - setState(() { - widget.removeHistory(history); - }); - }, - addHistory: (history){ - setState(() { - createAndAddHistory( - history); - }); - }, - addSelectedHistories: (){ - widget.addSelectedHistories(); - }, - isServiceSelected: (master) =>isServiceSelected(master), - ), - ), - NetworkBaseView( - baseViewModel: model, - child: MasterKeyCheckboxSearchWidget( - model: model, - masterList: model.historyMedicalList, - removeHistory: (history){ - setState(() { - widget.removeHistory(history); - }); - }, - addHistory: (history){ - setState(() { - createAndAddHistory( - history); - }); - }, - addSelectedHistories: (){ - widget.addSelectedHistories(); - }, - isServiceSelected: (master) =>isServiceSelected(master), - ), - ), - ], - ), - ), - ), - ], - )), - ), - ), - )); - } - - createAndAddHistory(MasterKeyModel history) { - List myhistory = widget.myHistoryList.where((element) => - history.id == - element.selectedHistory.id && - history.typeId == - element.selectedHistory.typeId - ).toList(); - - if (myhistory.isEmpty) { - setState(() { - MySelectedHistory mySelectedHistory = MySelectedHistory( - remark: history.remarks ?? "", - selectedHistory: history, - isChecked: true); - widget.myHistoryList.add(mySelectedHistory); - }); - } else { - myhistory.first.isChecked = true; - } - } - - isServiceSelected(MasterKeyModel masterKey) { - Iterable history = - widget - .myHistoryList - .where((element) => - masterKey.id == element.selectedHistory.id && - masterKey.typeId == element.selectedHistory.typeId && - element.isChecked); - if (history.length > 0) { - return true; - } - return false; - } - -} 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 440252fa..8b2d4d39 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 @@ -22,6 +22,7 @@ import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; import '../custom_validation_error.dart'; +import 'bottom_sheet_title.dart'; class UpdateMedicationWidget extends StatefulWidget { final TextEditingController medicationController; @@ -206,48 +207,9 @@ class _AddMedicationState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - padding: - EdgeInsets.only(left: 0, right: 5, bottom: 5, top: 5), - decoration: BoxDecoration( - color: Colors.white, - ), - height: 115, - child: Container( - padding: EdgeInsets.only(left: 10, right: 10), - margin: EdgeInsets.only(top: 40), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - RichText( - text: TextSpan( - style: TextStyle( - fontSize: 20, color: Colors.black), - children: [ - new TextSpan( - text: TranslationBase.of(context) - .addMedication, - style: TextStyle( - color: Color(0xFF2B353E), - fontWeight: FontWeight.bold, - fontFamily: 'Poppins', - fontSize: 20)), - ], - ), - ), - InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Icon(FontAwesomeIcons.times, - size: 30, color: Color(0xFF2B353E))) - ], - ), - ], - ), - ), + + BottomSheetTitle( + title: TranslationBase.of(context).addMedication, ), SizedBox( height: 10, 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 6306e069..2b17709d 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 @@ -18,8 +18,8 @@ import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; 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/allergies/update_allergies_widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/history/update_history_widget.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:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; From 344ca9c55a009d9606ca86205d7d5d1ecd073363 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 13 Apr 2021 16:24:34 +0300 Subject: [PATCH 2/3] refactor code in subjective step2 --- .../subjective/medication/add_medication.dart | 472 +++++++++ .../medication/update_medication_widget.dart | 118 +++ .../subjective/update_Chief_complaints.dart | 2 +- .../subjective/update_medication_widget.dart | 569 ----------- ..._key_checkbox_search_allergies_widget.dart | 916 +++++++++--------- 5 files changed, 1046 insertions(+), 1031 deletions(-) create mode 100644 lib/widgets/patients/profile/soap_update/subjective/medication/add_medication.dart create mode 100644 lib/widgets/patients/profile/soap_update/subjective/medication/update_medication_widget.dart delete mode 100644 lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart diff --git a/lib/widgets/patients/profile/soap_update/subjective/medication/add_medication.dart b/lib/widgets/patients/profile/soap_update/subjective/medication/add_medication.dart new file mode 100644 index 00000000..2c93040f --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/subjective/medication/add_medication.dart @@ -0,0 +1,472 @@ +// ignore: must_be_immutable +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; +import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; +import 'package:doctor_app_flutter/core/model/get_medication_response_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/app-textfield-custom.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: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'; +import '../bottom_sheet_title.dart'; + +class AddMedication extends StatefulWidget { + final Function addMedicationFun; + TextEditingController medicationController; + + AddMedication({Key key, this.addMedicationFun, this.medicationController}) + : super(key: key); + + @override + _AddMedicationState createState() => _AddMedicationState(); +} + +class _AddMedicationState extends State { + MasterKeyModel _selectedMedicationDose; + MasterKeyModel _selectedMedicationStrength; + MasterKeyModel _selectedMedicationRoute; + MasterKeyModel _selectedMedicationFrequency; + + MasterKeyModel _selectedAllergy; + TextEditingController doseController = TextEditingController(); + TextEditingController strengthController = TextEditingController(); + TextEditingController routeController = TextEditingController(); + TextEditingController frequencyController = TextEditingController(); + GetMedicationResponseModel _selectedMedication; + + GlobalKey key = + new GlobalKey>(); + bool isFormSubmitted = false; + + InputDecoration textFieldSelectorDecoration( + String hintText, String selectedText, bool isDropDown, + {IconData icon}) { + return InputDecoration( + filled: true, + fillColor: Colors.white, + + contentPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.grey, width: 0.00), + borderRadius: BorderRadius.circular(8), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.grey, width: 0.00), + borderRadius: BorderRadius.circular(8), + ), + disabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.grey, width: 0.00), + borderRadius: BorderRadius.circular(8), + ), + hintText: selectedText != null ? selectedText : hintText, + suffixIcon: isDropDown ? Icon(icon ?? Icons.arrow_drop_down) : null, + hintStyle: TextStyle( + fontSize: 10, + color: Theme + .of(context) + .hintColor, + fontWeight: FontWeight.w700 + ), + ); + } + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + final screenSize = MediaQuery + .of(context) + .size; + return FractionallySizedBox( + child: BaseView( + onModelReady: (model) async { + if (model.medicationStrengthList.length == 0) { + await model.getMasterLookup(MasterKeysService.MedicationStrength,); + } + if (model.medicationFrequencyList.length == 0) { + await model.getMasterLookup(MasterKeysService.MedicationFrequency); + } + if (model.medicationDoseTimeList.length == 0) { + await model.getMasterLookup(MasterKeysService.MedicationDoseTime); + } + if (model.medicationRouteList.length == 0) { + await model.getMasterLookup(MasterKeysService.MedicationRoute); + } + if (model.allMedicationList.length == 0) + await model.getMedicationList(); + }, + builder: (_, model, w) => + AppScaffold( + baseViewModel: model, + isShowAppBar: false, + body: Center( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + + BottomSheetTitle( + title: TranslationBase.of(context).addMedication, + ), + SizedBox( + height: 10, + ), + SizedBox( + height: 16, + ), + Expanded( + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + children: [ + SizedBox( + height: 16, + ), + SizedBox( + height: 16, + ), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: model.allMedicationList != null + ? () { + setState(() { + _selectedMedication = null; + }); + } + : null, + child: _selectedMedication == null + ? AutoCompleteTextField< + GetMedicationResponseModel>( + decoration: + textFieldSelectorDecoration( + + TranslationBase.of(context) + .searchMedicineNameHere, + _selectedMedication != null + ? _selectedMedication + .genericName + : null, + true, + icon: EvaIcons.search), + itemSubmitted: (item) => setState( + () => + _selectedMedication = item), + key: key, + suggestions: + model.allMedicationList, + itemBuilder: (context, + suggestion) => + new Padding( + child: Texts(suggestion + .description + + '/' + + suggestion.genericName), + padding: + EdgeInsets.all(8.0)), + itemSorter: (a, b) => 1, + itemFilter: (suggestion, input) => + suggestion.genericName + .toLowerCase() + .startsWith( + input.toLowerCase()) || + suggestion.description + .toLowerCase() + .startsWith( + input.toLowerCase()) || + suggestion.keywords + .toLowerCase() + .startsWith( + input.toLowerCase()), + ) + : AppTextFieldCustom( + hintText: _selectedMedication != null + ? _selectedMedication + .description + + (' (${_selectedMedication.genericName} )') + : TranslationBase.of(context) + .searchMedicineNameHere, + minLines: 2, + maxLines: 2, + enabled: false, + ), + ), + ), + if (isFormSubmitted && + _selectedMedication == null) + CustomValidationError(), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + enabled: false, + onClick: model.medicationDoseTimeList != null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: model.medicationDoseTimeList, + okText: + TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationDose = + selectedValue; + + doseController + .text = projectViewModel + .isArabic + ? _selectedMedicationDose + .nameAr + : _selectedMedicationDose + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: + TranslationBase.of(context).doseTime, + //TODO add translation + maxLines: 2, + minLines: 2, + isDropDown: true, + controller: doseController, + ), + SizedBox( + height: 5, + ), + if (isFormSubmitted && + _selectedMedicationDose == null) + CustomValidationError(), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + enabled: false, + isDropDown: true, + onClick: model.medicationStrengthList != null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: model.medicationStrengthList, + okText: + TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationStrength = + selectedValue; + + strengthController + .text = projectViewModel + .isArabic + ? _selectedMedicationStrength + .nameAr + : _selectedMedicationStrength + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: + TranslationBase.of(context).strength, + // hintColor: Colors.black, + // fontWeight: FontWeight.w600, + maxLines: 2, + minLines: 2, + controller: strengthController, + ), + SizedBox( + height: 5, + ), + if (isFormSubmitted && + _selectedMedicationStrength == null) + CustomValidationError(), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + enabled: false, + isDropDown: true, + onClick: model.medicationRouteList != null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: model.medicationRouteList, + okText: + TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationRoute = + selectedValue; + + routeController + .text = projectViewModel + .isArabic + ? _selectedMedicationRoute + .nameAr + : _selectedMedicationRoute + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: TranslationBase.of(context).route, + maxLines: 2, + minLines: 2, + controller: routeController, + ), + SizedBox( + height: 5, + ), + if (isFormSubmitted && + _selectedMedicationRoute == null) + CustomValidationError(), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + onClick: model.medicationFrequencyList != null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: model.medicationFrequencyList, + okText: + TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationFrequency = + selectedValue; + + frequencyController + .text = projectViewModel + .isArabic + ? _selectedMedicationFrequency + .nameAr + : _selectedMedicationFrequency + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: + TranslationBase.of(context).frequency, + //TODO add translation + enabled: false, + // hintColor: Colors.black, + maxLines: 2, + minLines: 2, + isDropDown: true, + controller: frequencyController, + ), + SizedBox( + height: 5, + ), + if (isFormSubmitted && + _selectedMedicationFrequency == null) + CustomValidationError(), + SizedBox( + height: 30, + ), + ], + )), + ), + ), + ]), + ), + ), + bottomSheet: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(10.0), + ), + border: Border.all(color: HexColor('#707070'), width: 0.30), + ), + height: MediaQuery.of(context).size.height * 0.1, + width: double.infinity, + child: Column( + children: [ + SizedBox( + height: 10, + ), + Container( + child: FractionallySizedBox( + widthFactor: .80, + child: Center( + child: AppButton( + title: TranslationBase.of(context).addMedication.toUpperCase(), + color: Color(0xFF359846), + onPressed: () { + setState(() { + isFormSubmitted = true; + }); + if (_selectedMedication != null && + _selectedMedicationDose != null && + _selectedMedicationStrength != null && + _selectedMedicationRoute != null && + _selectedMedicationFrequency != null) { + widget.medicationController.text = widget + .medicationController.text + + '${_selectedMedication.description} (${TranslationBase.of(context).doseTime} ) ${doseController.text} (${TranslationBase.of(context).strength}) ${strengthController.text} (${TranslationBase.of(context).route}) ${routeController.text} (${TranslationBase.of(context).frequency}) ${frequencyController.text} \n \n'; + Navigator.of(context).pop(); + } + }, + ), + ), + ), + ), + SizedBox( + height: 5, + ), + ], + ), + ), + ), + ), + ); + } +} + + + diff --git a/lib/widgets/patients/profile/soap_update/subjective/medication/update_medication_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/medication/update_medication_widget.dart new file mode 100644 index 00000000..e2cb28c4 --- /dev/null +++ b/lib/widgets/patients/profile/soap_update/subjective/medication/update_medication_widget.dart @@ -0,0 +1,118 @@ +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; +import 'package:doctor_app_flutter/core/model/get_medication_response_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app-textfield-custom.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: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:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:provider/provider.dart'; + +import '../../custom_validation_error.dart'; +import '../bottom_sheet_title.dart'; +import 'add_medication.dart'; + +class UpdateMedicationWidget extends StatefulWidget { + final TextEditingController medicationController; + + UpdateMedicationWidget({ + Key key, + this.medicationController, + }); + + @override + _UpdateMedicationWidgetState createState() => _UpdateMedicationWidgetState(); +} + +class _UpdateMedicationWidgetState extends State { + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + + return Column( + children: [ + InkWell( + onTap: () { + openMedicationList(context); + }, + child: Container( + padding: EdgeInsets.symmetric( + vertical: 8, horizontal: 8.0), + margin: + EdgeInsets.symmetric(vertical: 8), + decoration: BoxDecoration( + border: Border.all( + color: Colors.grey.shade400, + width: 0.5), + borderRadius: BorderRadius.all( + Radius.circular(8), + ), + color: Colors.white, + ), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + "${TranslationBase.of(context).addMedication}", + fontSize: SizeConfig + .textMultiplier * + 1.8, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ], + )), + Icon( + Icons.add_box_rounded, + size: 25, + ) + ], + ), + ), + ), + SizedBox( + height: 20, + ) + ], + ); + } + + + openMedicationList(BuildContext context) { + showModalBottomSheet( + backgroundColor: Colors.white, + isScrollControlled: true, + isDismissible: false, + context: context, + builder: (context) { + return AddMedication( + addMedicationFun: (MySelectedAllergy mySelectedAllergy) {}, + medicationController: widget.medicationController, + ); + }); + } +} + + + 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 1b159ec0..bb66fd90 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,5 +1,5 @@ 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/patients/profile/soap_update/subjective/medication/update_medication_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/new_text_Field.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; 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 deleted file mode 100644 index 8b2d4d39..00000000 --- a/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart +++ /dev/null @@ -1,569 +0,0 @@ -import 'package:autocomplete_textfield/autocomplete_textfield.dart'; -import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; -import 'package:doctor_app_flutter/core/model/get_medication_response_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; -import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; -import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart'; -import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/shared/Text.dart'; -import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; -import 'package:doctor_app_flutter/widgets/shared/app-textfield-custom.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: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:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:hexcolor/hexcolor.dart'; -import 'package:provider/provider.dart'; - -import '../custom_validation_error.dart'; -import 'bottom_sheet_title.dart'; - -class UpdateMedicationWidget extends StatefulWidget { - final TextEditingController medicationController; - - UpdateMedicationWidget({ - Key key, - this.medicationController, - }); - - @override - _UpdateMedicationWidgetState createState() => _UpdateMedicationWidgetState(); -} - -class _UpdateMedicationWidgetState extends State { - @override - Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); - - return Column( - children: [ - InkWell( - onTap: () { - openMedicationList(context); - }, - child: Container( - padding: EdgeInsets.symmetric( - vertical: 8, horizontal: 8.0), - margin: - EdgeInsets.symmetric(vertical: 8), - decoration: BoxDecoration( - border: Border.all( - color: Colors.grey.shade400, - width: 0.5), - borderRadius: BorderRadius.all( - Radius.circular(8), - ), - color: Colors.white, - ), - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Expanded( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - "${TranslationBase.of(context).addMedication}", - fontSize: SizeConfig - .textMultiplier * - 1.8, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - ], - )), - Icon( - Icons.add_box_rounded, - size: 25, - ) - ], - ), - ), - ), - SizedBox( - height: 20, - ) - ], - ); - } - - - openMedicationList(BuildContext context) { - showModalBottomSheet( - backgroundColor: Colors.white, - isScrollControlled: true, - isDismissible: false, - context: context, - builder: (context) { - return AddMedication( - addMedicationFun: (MySelectedAllergy mySelectedAllergy) {}, - medicationController: widget.medicationController, - ); - }); - } -} - -// ignore: must_be_immutable -class AddMedication extends StatefulWidget { - final Function addMedicationFun; - TextEditingController medicationController; - - AddMedication({Key key, this.addMedicationFun, this.medicationController}) - : super(key: key); - - @override - _AddMedicationState createState() => _AddMedicationState(); -} - -class _AddMedicationState extends State { - MasterKeyModel _selectedMedicationDose; - MasterKeyModel _selectedMedicationStrength; - MasterKeyModel _selectedMedicationRoute; - MasterKeyModel _selectedMedicationFrequency; - - MasterKeyModel _selectedAllergy; - TextEditingController doseController = TextEditingController(); - TextEditingController strengthController = TextEditingController(); - TextEditingController routeController = TextEditingController(); - TextEditingController frequencyController = TextEditingController(); - GetMedicationResponseModel _selectedMedication; - - GlobalKey key = - new GlobalKey>(); - bool isFormSubmitted = false; - - InputDecoration textFieldSelectorDecoration( - String hintText, String selectedText, bool isDropDown, - {IconData icon}) { - return InputDecoration( - filled: true, - fillColor: Colors.white, - - contentPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.grey, width: 0.00), - borderRadius: BorderRadius.circular(8), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.grey, width: 0.00), - borderRadius: BorderRadius.circular(8), - ), - disabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.grey, width: 0.00), - borderRadius: BorderRadius.circular(8), - ), - hintText: selectedText != null ? selectedText : hintText, - suffixIcon: isDropDown ? Icon(icon ?? Icons.arrow_drop_down) : null, - hintStyle: TextStyle( - fontSize: 10, - color: Theme - .of(context) - .hintColor, - fontWeight: FontWeight.w700 - ), - ); - } - - @override - Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); - final screenSize = MediaQuery - .of(context) - .size; - return FractionallySizedBox( - child: BaseView( - onModelReady: (model) async { - if (model.medicationStrengthList.length == 0) { - await model.getMasterLookup(MasterKeysService.MedicationStrength,); - } - if (model.medicationFrequencyList.length == 0) { - await model.getMasterLookup(MasterKeysService.MedicationFrequency); - } - if (model.medicationDoseTimeList.length == 0) { - await model.getMasterLookup(MasterKeysService.MedicationDoseTime); - } - if (model.medicationRouteList.length == 0) { - await model.getMasterLookup(MasterKeysService.MedicationRoute); - } - if (model.allMedicationList.length == 0) - await model.getMedicationList(); - }, - builder: (_, model, w) => - AppScaffold( - baseViewModel: model, - isShowAppBar: false, - body: Center( - child: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - - BottomSheetTitle( - title: TranslationBase.of(context).addMedication, - ), - SizedBox( - height: 10, - ), - SizedBox( - height: 16, - ), - Expanded( - child: Center( - child: FractionallySizedBox( - widthFactor: 0.9, - child: Column( - children: [ - SizedBox( - height: 16, - ), - SizedBox( - height: 16, - ), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: model.allMedicationList != null - ? () { - setState(() { - _selectedMedication = null; - }); - } - : null, - child: _selectedMedication == null - ? AutoCompleteTextField< - GetMedicationResponseModel>( - decoration: - textFieldSelectorDecoration( - - TranslationBase.of(context) - .searchMedicineNameHere, - _selectedMedication != null - ? _selectedMedication - .genericName - : null, - true, - icon: EvaIcons.search), - itemSubmitted: (item) => setState( - () => - _selectedMedication = item), - key: key, - suggestions: - model.allMedicationList, - itemBuilder: (context, - suggestion) => - new Padding( - child: Texts(suggestion - .description + - '/' + - suggestion.genericName), - padding: - EdgeInsets.all(8.0)), - itemSorter: (a, b) => 1, - itemFilter: (suggestion, input) => - suggestion.genericName - .toLowerCase() - .startsWith( - input.toLowerCase()) || - suggestion.description - .toLowerCase() - .startsWith( - input.toLowerCase()) || - suggestion.keywords - .toLowerCase() - .startsWith( - input.toLowerCase()), - ) - : AppTextFieldCustom( - hintText: _selectedMedication != null - ? _selectedMedication - .description + - (' (${_selectedMedication.genericName} )') - : TranslationBase.of(context) - .searchMedicineNameHere, - minLines: 2, - maxLines: 2, - enabled: false, - ), - ), - ), - if (isFormSubmitted && - _selectedMedication == null) - CustomValidationError(), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - enabled: false, - onClick: model.medicationDoseTimeList != null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: model.medicationDoseTimeList, - okText: - TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationDose = - selectedValue; - - doseController - .text = projectViewModel - .isArabic - ? _selectedMedicationDose - .nameAr - : _selectedMedicationDose - .nameEn; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: - TranslationBase.of(context).doseTime, - //TODO add translation - maxLines: 2, - minLines: 2, - isDropDown: true, - controller: doseController, - ), - SizedBox( - height: 5, - ), - if (isFormSubmitted && - _selectedMedicationDose == null) - CustomValidationError(), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - enabled: false, - isDropDown: true, - onClick: model.medicationStrengthList != null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: model.medicationStrengthList, - okText: - TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationStrength = - selectedValue; - - strengthController - .text = projectViewModel - .isArabic - ? _selectedMedicationStrength - .nameAr - : _selectedMedicationStrength - .nameEn; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: - TranslationBase.of(context).strength, - // hintColor: Colors.black, - // fontWeight: FontWeight.w600, - maxLines: 2, - minLines: 2, - controller: strengthController, - ), - SizedBox( - height: 5, - ), - if (isFormSubmitted && - _selectedMedicationStrength == null) - CustomValidationError(), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - enabled: false, - isDropDown: true, - onClick: model.medicationRouteList != null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: model.medicationRouteList, - okText: - TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationRoute = - selectedValue; - - routeController - .text = projectViewModel - .isArabic - ? _selectedMedicationRoute - .nameAr - : _selectedMedicationRoute - .nameEn; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: TranslationBase.of(context).route, - maxLines: 2, - minLines: 2, - controller: routeController, - ), - SizedBox( - height: 5, - ), - if (isFormSubmitted && - _selectedMedicationRoute == null) - CustomValidationError(), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - onClick: model.medicationFrequencyList != null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: model.medicationFrequencyList, - okText: - TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationFrequency = - selectedValue; - - frequencyController - .text = projectViewModel - .isArabic - ? _selectedMedicationFrequency - .nameAr - : _selectedMedicationFrequency - .nameEn; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: - TranslationBase.of(context).frequency, - //TODO add translation - enabled: false, - // hintColor: Colors.black, - maxLines: 2, - minLines: 2, - isDropDown: true, - controller: frequencyController, - ), - SizedBox( - height: 5, - ), - if (isFormSubmitted && - _selectedMedicationFrequency == null) - CustomValidationError(), - SizedBox( - height: 30, - ), - ], - )), - ), - ), - ]), - ), - ), - bottomSheet: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(10.0), - ), - border: Border.all(color: HexColor('#707070'), width: 0.30), - ), - height: MediaQuery.of(context).size.height * 0.1, - width: double.infinity, - child: Column( - children: [ - SizedBox( - height: 10, - ), - Container( - child: FractionallySizedBox( - widthFactor: .80, - child: Center( - child: AppButton( - title: TranslationBase.of(context).addMedication.toUpperCase(), - color: Color(0xFF359846), - onPressed: () { - setState(() { - isFormSubmitted = true; - }); - if (_selectedMedication != null && - _selectedMedicationDose != null && - _selectedMedicationStrength != null && - _selectedMedicationRoute != null && - _selectedMedicationFrequency != null) { - widget.medicationController.text = widget - .medicationController.text + - '${_selectedMedication.description} (${TranslationBase.of(context).doseTime} ) ${doseController.text} (${TranslationBase.of(context).strength}) ${strengthController.text} (${TranslationBase.of(context).route}) ${routeController.text} (${TranslationBase.of(context).frequency}) ${frequencyController.text} \n \n'; - Navigator.of(context).pop(); - } - }, - ), - ), - ), - ), - SizedBox( - height: 5, - ), - ], - ), - ), - ), - ), - ); - } -} - - - - - - diff --git a/lib/widgets/shared/master_key_checkbox_search_allergies_widget.dart b/lib/widgets/shared/master_key_checkbox_search_allergies_widget.dart index f85d2fe6..4a4f765a 100644 --- a/lib/widgets/shared/master_key_checkbox_search_allergies_widget.dart +++ b/lib/widgets/shared/master_key_checkbox_search_allergies_widget.dart @@ -64,237 +64,289 @@ class _MasterKeyCheckboxSearchAllergiesWidgetState return Container( child: Column( children: [ - Expanded( - child: Container( - height: MediaQuery.of(context).size.height * 0.62, - child: Center( - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: Column( - children: [ - TextFields( - hintText: widget.hintSearchText ?? - TranslationBase.of(context).selectAllergy, - borderWidth: 0.0, - padding: EdgeInsets.all(20), - borderRadius: 0, - suffixIcon: EvaIcons.search, - onChanged: (value) { - filterSearchResults(value); - }, - ), - SizedBox( - height: 10, - ), - Expanded( - child: FractionallySizedBox( - widthFactor: 0.9, - child: Container( - height: MediaQuery.of(context).size.height * 0.60, - child: ListView.builder( - itemCount: items.length, - itemBuilder: (context, index) { - bool isSelected = - widget.isServiceSelected(items[index]); - MySelectedAllergy mySelectedAllergy; - if (isSelected) { - mySelectedAllergy = - widget.getServiceSelectedAllergy( - items[index]); - } - TextEditingController remarkController = - TextEditingController( - text: isSelected - ? mySelectedAllergy.remark - : null); - TextEditingController severityController = - TextEditingController( - text: isSelected - ? mySelectedAllergy - .selectedAllergySeverity != - null - ? projectViewModel.isArabic - ? mySelectedAllergy - .selectedAllergySeverity - .nameAr - : mySelectedAllergy - .selectedAllergySeverity - .nameEn - : null - : null); - return HeaderBodyExpandableNotifier( - headerWidget: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Checkbox( - value: - widget.isServiceSelected( - items[index]), - activeColor: Colors.red[800], - onChanged: (bool newValue) { - setState(() { - if (widget - .isServiceSelected( - items[index])) { - widget.removeAllergy( - items[index]); - } else { - // TODO add Allergy - - MySelectedAllergy - mySelectedAllergy = - new MySelectedAllergy( - selectedAllergy: - items[index], - selectedAllergySeverity: - _selectedAllergySeverity, - remark: null, - isChecked: true, - isExpanded: true); - widget.addAllergy( - mySelectedAllergy); - } - }); - }), - InkWell( - onTap: () { + Container( + height: MediaQuery.of(context).size.height * 0.70, + child: Center( + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: Column( + children: [ + TextFields( + hintText: widget.hintSearchText ?? + TranslationBase.of(context).selectAllergy, + borderWidth: 0.0, + padding: EdgeInsets.all(20), + borderRadius: 0, + suffixIcon: EvaIcons.search, + onChanged: (value) { + filterSearchResults(value); + }, + ), + SizedBox( + height: 10, + ), + Expanded( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Container( + height: MediaQuery.of(context).size.height * 0.60, + child: ListView.builder( + itemCount: items.length, + itemBuilder: (context, index) { + bool isSelected = + widget.isServiceSelected(items[index]); + MySelectedAllergy mySelectedAllergy; + if (isSelected) { + mySelectedAllergy = + widget.getServiceSelectedAllergy( + items[index]); + } + TextEditingController remarkController = + TextEditingController( + text: isSelected + ? mySelectedAllergy.remark + : null); + TextEditingController severityController = + TextEditingController( + text: isSelected + ? mySelectedAllergy + .selectedAllergySeverity != + null + ? projectViewModel.isArabic + ? mySelectedAllergy + .selectedAllergySeverity + .nameAr + : mySelectedAllergy + .selectedAllergySeverity + .nameEn + : null + : null); + return HeaderBodyExpandableNotifier( + headerWidget: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Checkbox( + value: + widget.isServiceSelected( + items[index]), + activeColor: Colors.red[800], + onChanged: (bool newValue) { setState(() { if (widget .isServiceSelected( - items[index])) { + items[index])) { widget.removeAllergy( items[index]); } else { - // TODO add Allergy - MySelectedAllergy - mySelectedAllergy = - new MySelectedAllergy( - selectedAllergy: - items[index], - selectedAllergySeverity: - _selectedAllergySeverity, - remark: null, - isChecked: true, - isExpanded: true); + mySelectedAllergy = + new MySelectedAllergy( + selectedAllergy: + items[index], + selectedAllergySeverity: + _selectedAllergySeverity, + remark: null, + isChecked: true, + isExpanded: true); widget.addAllergy( mySelectedAllergy); } }); - }, - child: Expanded( - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Container( + }), + InkWell( + onTap: () { + setState(() { + if (widget + .isServiceSelected( + items[index])) { + widget.removeAllergy( + items[index]); + } else { + // TODO add Allergy + + MySelectedAllergy + mySelectedAllergy = + new MySelectedAllergy( + selectedAllergy: + items[index], + selectedAllergySeverity: + _selectedAllergySeverity, + remark: null, + isChecked: true, + isExpanded: true); + widget.addAllergy( + mySelectedAllergy); + } + }); + }, + child: Padding( + padding: const EdgeInsets + .symmetric( + horizontal: 10, + vertical: 0), + child: Container( - child: AppText( - projectViewModel.isArabic + child: AppText( + projectViewModel.isArabic + ? items[index] + .nameAr != + "" ? items[index] - .nameAr != - "" - ? items[index] - .nameAr - : items[index] - .nameEn - : items[index].nameEn, - color: Color(0xFF575757), - fontSize: 16, - fontWeight: - FontWeight.w600, - ), - width: MediaQuery.of(context).size.width * 0.55, - ), + .nameAr + : items[index] + .nameEn + : items[index].nameEn, + color: Color(0xFF575757), + fontSize: 16, + fontWeight: + FontWeight.w600, ), + width: MediaQuery.of(context).size.width * 0.55, ), ), - ], - ), - InkWell( - onTap: () { - if (mySelectedAllergy != null) { - setState(() { - mySelectedAllergy - .isExpanded = - mySelectedAllergy - .isExpanded - ? false - : true; - }); - } + ), + ], + ), + InkWell( + onTap: () { + if (mySelectedAllergy != null) { + setState(() { + mySelectedAllergy + .isExpanded = + mySelectedAllergy + .isExpanded + ? false + : true; + }); + } + }, + child: Icon((mySelectedAllergy != + null + ? mySelectedAllergy + .isExpanded + : false) + ? EvaIcons + .arrowIosUpwardOutline + : EvaIcons + .arrowIosDownwardOutline)) + ], + ), + bodyWidget: Column( + children: [ + TextFields( + onTapTextFields: widget.model + .allergySeverityList != + null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: widget.model + .allergySeverityList, + okText: + TranslationBase.of( + context) + .ok, + okFunction: + (selectedValue) { + setState(() { + mySelectedAllergy + .selectedAllergySeverity = + selectedValue; + }); }, - child: Icon((mySelectedAllergy != - null - ? mySelectedAllergy - .isExpanded - : false) - ? EvaIcons - .arrowIosUpwardOutline - : EvaIcons - .arrowIosDownwardOutline)) - ], + ); + showDialog( + barrierDismissible: + false, + context: context, + builder: (BuildContext + context) { + return dialog; + }, + ); + } + : null, + hasLabelText: + mySelectedAllergy != null && + mySelectedAllergy + .selectedAllergySeverity != + null + ? 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, ), - bodyWidget: Column( - children: [ - TextFields( - onTapTextFields: widget.model - .allergySeverityList != - null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: widget.model - .allergySeverityList, - okText: - TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - mySelectedAllergy - .selectedAllergySeverity = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: - false, - context: context, - builder: (BuildContext - context) { - return dialog; - }, - ); - } - : null, + if(isSubmitted && + mySelectedAllergy + .selectedAllergySeverity == null) + Row( + + children: [ + CustomValidationError(), + ], + mainAxisAlignment: MainAxisAlignment.start, + ), + + SizedBox( + height: 10, + ), + Container( + margin: EdgeInsets.only( + left: 0, right: 0, top: 15), + child: TextFields( hasLabelText: - mySelectedAllergy != null && - mySelectedAllergy - .selectedAllergySeverity != - null + remarkController.text != + '' ? true : false, showLabelText: true, - hintText: - TranslationBase - .of(context) - .selectSeverity, + hintText: TranslationBase + .of( + context) + .remarks, fontSize: 13.5, - readOnly: true, // hintColor: Colors.black, fontWeight: FontWeight.w600, - maxLines: 2, - minLines: 1, - controller: severityController, + maxLines: 25, + minLines: 10, + initialValue: isSelected + ? mySelectedAllergy + .remark : '', + // controller: remarkControlle + + onChanged: (value) { + if (isSelected) { + mySelectedAllergy + .remark = value; + }; + }, + validator: (value) { if (value == null) return TranslationBase @@ -304,203 +356,203 @@ class _MasterKeyCheckboxSearchAllergiesWidgetState else return null; }), - SizedBox( - height: 5, - ), - if(isSubmitted && - mySelectedAllergy - .selectedAllergySeverity == null) - Row( - - children: [ - CustomValidationError(), - ], - mainAxisAlignment: MainAxisAlignment.start, - ), - - SizedBox( - height: 10, - ), - Container( - margin: EdgeInsets.only( - left: 0, right: 0, top: 15), - child: TextFields( - hasLabelText: - remarkController.text != - '' - ? true - : false, - showLabelText: true, - hintText: TranslationBase - .of( - context) - .remarks, - fontSize: 13.5, - // hintColor: Colors.black, - fontWeight: FontWeight.w600, - maxLines: 25, - minLines: 10, - initialValue: isSelected - ? mySelectedAllergy - .remark : '', - // controller: remarkControlle - - onChanged: (value) { - if (isSelected) { - mySelectedAllergy - .remark = value; - }; - }, + ), + SizedBox( + height: 10, + ), + ],), + isExpand: mySelectedAllergy != null + ? mySelectedAllergy.isExpanded + : false, + ); - validator: (value) { - if (value == null) - return TranslationBase - .of( - context) - .emptyMessage; - else - return null; - }), - ), - SizedBox( - height: 10, - ), - ],), - isExpand: mySelectedAllergy != null - ? mySelectedAllergy.isExpanded - : false, - ); + Column( + children: [ + InkWell( + onTap: () { + setState(() { + if (widget.isServiceSelected( + items[index])) { + widget + .removeAllergy( + items[index]); + } else { + // TODO add Allergy - Column( - children: [ - InkWell( - onTap: () { - setState(() { - if (widget.isServiceSelected( - items[index])) { - widget - .removeAllergy( - items[index]); - } else { - // TODO add Allergy - - MySelectedAllergy - mySelectedAllergy = - new MySelectedAllergy( - selectedAllergy: - items[index], - selectedAllergySeverity: - _selectedAllergySeverity, - remark: null, - isChecked: true); - widget.addAllergy( - mySelectedAllergy); - } - }); - }, - child: Column( - children: [ - Row( - children: [ - Checkbox( - value: widget - .isServiceSelected( - items[index]), - activeColor: - Colors.red[800], - onChanged: (bool newValue) { - // setState(() { - // if (widget - // .isServiceSelected(items[index])) { - // widget.removeHistory(items[index]); - // } else { - // widget.addHistory(items[index]); - // } - // }); - }), - Expanded( - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: AppText( - projectViewModel.isArabic - ? items[index] - .nameAr != - "" - ? items[index] - .nameAr - : items[index] - .nameEn - : items[index].nameEn, - color: Color(0xFF575757), - fontSize: 16, - fontWeight: - FontWeight.w600, - ), + MySelectedAllergy + mySelectedAllergy = + new MySelectedAllergy( + selectedAllergy: + items[index], + selectedAllergySeverity: + _selectedAllergySeverity, + remark: null, + isChecked: true); + widget.addAllergy( + mySelectedAllergy); + } + }); + }, + child: Column( + children: [ + Row( + children: [ + Checkbox( + value: widget + .isServiceSelected( + items[index]), + activeColor: + Colors.red[800], + onChanged: (bool newValue) { + // setState(() { + // if (widget + // .isServiceSelected(items[index])) { + // widget.removeHistory(items[index]); + // } else { + // widget.addHistory(items[index]); + // } + // }); + }), + Expanded( + child: Padding( + padding: const EdgeInsets + .symmetric( + horizontal: 10, + vertical: 0), + child: AppText( + projectViewModel.isArabic + ? items[index] + .nameAr != + "" + ? items[index] + .nameAr + : items[index] + .nameEn + : items[index].nameEn, + color: Color(0xFF575757), + fontSize: 16, + fontWeight: + FontWeight.w600, ), ), - ], + ), + ], + ), + if(widget + .isServiceSelected( + items[index])) + Column(children: [ + TextFields( + onTapTextFields: widget.model + .allergySeverityList != + null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: widget.model + .allergySeverityList, + okText: + TranslationBase.of( + context) + .ok, + okFunction: + (selectedValue) { + setState(() { + mySelectedAllergy + .selectedAllergySeverity = + selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: + false, + context: context, + builder: (BuildContext + context) { + return dialog; + }, + ); + } + : null, + hasLabelText: + mySelectedAllergy + .selectedAllergySeverity != + null + ? 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(widget - .isServiceSelected( - items[index])) - Column(children: [ - TextFields( - onTapTextFields: widget.model - .allergySeverityList != - null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: widget.model - .allergySeverityList, - okText: - TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - mySelectedAllergy - .selectedAllergySeverity = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: - false, - context: context, - builder: (BuildContext - context) { - return dialog; - }, - ); - } - : null, + if(isSubmitted && + mySelectedAllergy + .selectedAllergySeverity == null) + Row( + + children: [ + CustomValidationError(), + ], + mainAxisAlignment: MainAxisAlignment.start, + ), + + SizedBox( + height: 10, + ), + Container( + margin: EdgeInsets.only( + left: 0, right: 0, top: 15), + child: TextFields( hasLabelText: - mySelectedAllergy - .selectedAllergySeverity != - null + remarkController.text != + '' ? true : false, showLabelText: true, - hintText: - TranslationBase - .of(context) - .selectSeverity, + hintText: TranslationBase + .of( + context) + .remarks, fontSize: 13.5, - readOnly: true, // hintColor: Colors.black, fontWeight: FontWeight.w600, - maxLines: 2, - minLines: 1, - controller: severityController, + maxLines: 25, + minLines: 10, + initialValue: isSelected + ? mySelectedAllergy + .remark : '', + // controller: remarkControlle + + onChanged: (value) { + if (isSelected) { + mySelectedAllergy + .remark = value; + }; + }, + validator: (value) { if (value == null) return TranslationBase @@ -510,83 +562,25 @@ class _MasterKeyCheckboxSearchAllergiesWidgetState else return null; }), - SizedBox( - height: 5, - ), - if(isSubmitted && - mySelectedAllergy - .selectedAllergySeverity == null) - Row( - - children: [ - CustomValidationError(), - ], - mainAxisAlignment: MainAxisAlignment.start, - ), - - SizedBox( - height: 10, - ), - Container( - margin: EdgeInsets.only( - left: 0, right: 0, top: 15), - child: TextFields( - hasLabelText: - remarkController.text != - '' - ? true - : false, - showLabelText: true, - hintText: TranslationBase - .of( - context) - .remarks, - fontSize: 13.5, - // hintColor: Colors.black, - fontWeight: FontWeight.w600, - maxLines: 25, - minLines: 10, - initialValue: isSelected - ? mySelectedAllergy - .remark : '', - // controller: remarkControlle - - onChanged: (value) { - if (isSelected) { - mySelectedAllergy - .remark = value; - }; - }, - - validator: (value) { - if (value == null) - return TranslationBase - .of( - context) - .emptyMessage; - else - return null; - }), - ), - SizedBox( - height: 10, - ), - ],) - ], - ), + ), + SizedBox( + height: 10, + ), + ],) + ], ), - // DividerWithSpacesAround(), - ], - ); - }, - ), + ), + // DividerWithSpacesAround(), + ], + ); + }, ), ), ), - ], - ) - )), - ), + ), + ], + ) + )), ), SizedBox( height: 10, From e668fd3334c01dff14cad6c7f2cc1e987365539a Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 13 Apr 2021 16:57:28 +0300 Subject: [PATCH 3/3] fix overflow in allergies --- .../allergies/update_allergies_widget.dart | 2 +- ..._key_checkbox_search_allergies_widget.dart | 793 +++++++----------- 2 files changed, 284 insertions(+), 511 deletions(-) diff --git a/lib/widgets/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart index 65cd1d63..5fa3535b 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart @@ -246,7 +246,7 @@ class _UpdateAllergiesWidgetState extends State { widget.myAllergiesList.add(element); } }); - changeParentState(); + // changeParentState(); Navigator.of(context).pop(); } else { helpers.showErrorToast(TranslationBase diff --git a/lib/widgets/shared/master_key_checkbox_search_allergies_widget.dart b/lib/widgets/shared/master_key_checkbox_search_allergies_widget.dart index 4a4f765a..52aa5e99 100644 --- a/lib/widgets/shared/master_key_checkbox_search_allergies_widget.dart +++ b/lib/widgets/shared/master_key_checkbox_search_allergies_widget.dart @@ -7,11 +7,13 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/custom_validation_error.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/new_text_Field.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'app-textfield-custom.dart'; import 'app_texts_widget.dart'; import 'dialogs/master_key_dailog.dart'; import 'expandable-widget-header-body.dart'; @@ -62,542 +64,313 @@ class _MasterKeyCheckboxSearchAllergiesWidgetState Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); return Container( - child: Column( - children: [ - Container( - height: MediaQuery.of(context).size.height * 0.70, - child: Center( - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: Column( - children: [ - TextFields( - hintText: widget.hintSearchText ?? - TranslationBase.of(context).selectAllergy, - borderWidth: 0.0, - padding: EdgeInsets.all(20), - borderRadius: 0, - suffixIcon: EvaIcons.search, - onChanged: (value) { - filterSearchResults(value); - }, - ), - SizedBox( - height: 10, - ), - Expanded( - child: FractionallySizedBox( - widthFactor: 0.9, - child: Container( - height: MediaQuery.of(context).size.height * 0.60, - child: ListView.builder( - itemCount: items.length, - itemBuilder: (context, index) { - bool isSelected = - widget.isServiceSelected(items[index]); - MySelectedAllergy mySelectedAllergy; - if (isSelected) { - mySelectedAllergy = - widget.getServiceSelectedAllergy( - items[index]); - } - TextEditingController remarkController = - TextEditingController( - text: isSelected - ? mySelectedAllergy.remark - : null); - TextEditingController severityController = - TextEditingController( - text: isSelected - ? mySelectedAllergy - .selectedAllergySeverity != - null - ? projectViewModel.isArabic - ? mySelectedAllergy - .selectedAllergySeverity - .nameAr - : mySelectedAllergy - .selectedAllergySeverity - .nameEn - : null - : null); - return HeaderBodyExpandableNotifier( - headerWidget: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Checkbox( - value: - widget.isServiceSelected( - items[index]), - activeColor: Colors.red[800], - onChanged: (bool newValue) { - setState(() { - if (widget - .isServiceSelected( - items[index])) { - widget.removeAllergy( - items[index]); - } else { - MySelectedAllergy - mySelectedAllergy = - new MySelectedAllergy( - selectedAllergy: - items[index], - selectedAllergySeverity: - _selectedAllergySeverity, - remark: null, - isChecked: true, - isExpanded: true); - widget.addAllergy( - mySelectedAllergy); - } - }); - }), - InkWell( - onTap: () { - setState(() { - if (widget - .isServiceSelected( - items[index])) { - widget.removeAllergy( - items[index]); - } else { - // TODO add Allergy - - MySelectedAllergy - mySelectedAllergy = - new MySelectedAllergy( - selectedAllergy: - items[index], - selectedAllergySeverity: - _selectedAllergySeverity, - remark: null, - isChecked: true, - isExpanded: true); - widget.addAllergy( - mySelectedAllergy); - } - }); - }, - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Container( - - child: AppText( - projectViewModel.isArabic - ? items[index] - .nameAr != - "" - ? items[index] - .nameAr - : items[index] - .nameEn - : items[index].nameEn, - color: Color(0xFF575757), - fontSize: 16, - fontWeight: - FontWeight.w600, - ), - width: MediaQuery.of(context).size.width * 0.55, - ), - ), - ), - ], - ), - InkWell( - onTap: () { - if (mySelectedAllergy != null) { - setState(() { - mySelectedAllergy - .isExpanded = - mySelectedAllergy - .isExpanded - ? false - : true; - }); - } - }, - child: Icon((mySelectedAllergy != - null - ? mySelectedAllergy - .isExpanded - : false) - ? EvaIcons - .arrowIosUpwardOutline - : EvaIcons - .arrowIosDownwardOutline)) - ], - ), - bodyWidget: Column( - children: [ - TextFields( - onTapTextFields: widget.model - .allergySeverityList != - null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: widget.model - .allergySeverityList, - okText: - TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - mySelectedAllergy - .selectedAllergySeverity = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: - false, - context: context, - builder: (BuildContext - context) { - return dialog; - }, - ); - } - : null, - hasLabelText: - mySelectedAllergy != null && - mySelectedAllergy - .selectedAllergySeverity != - null - ? 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(isSubmitted && - mySelectedAllergy - .selectedAllergySeverity == null) - Row( - - children: [ - CustomValidationError(), - ], - mainAxisAlignment: MainAxisAlignment.start, - ), - - SizedBox( - height: 10, - ), - Container( - margin: EdgeInsets.only( - left: 0, right: 0, top: 15), - child: TextFields( - hasLabelText: - remarkController.text != - '' - ? true - : false, - showLabelText: true, - hintText: TranslationBase - .of( - context) - .remarks, - fontSize: 13.5, - // hintColor: Colors.black, - fontWeight: FontWeight.w600, - maxLines: 25, - minLines: 10, - initialValue: isSelected - ? mySelectedAllergy - .remark : '', - // controller: remarkControlle - - onChanged: (value) { - if (isSelected) { - mySelectedAllergy - .remark = value; - }; - }, - - validator: (value) { - if (value == null) - return TranslationBase - .of( - context) - .emptyMessage; - else - return null; - }), - ), - SizedBox( - height: 10, - ), - ],), - isExpand: mySelectedAllergy != null - ? mySelectedAllergy.isExpanded - : false, - ); - - - - - Column( - children: [ - InkWell( - onTap: () { - setState(() { - if (widget.isServiceSelected( - items[index])) { - widget - .removeAllergy( - items[index]); - } else { - // TODO add Allergy - - MySelectedAllergy - mySelectedAllergy = - new MySelectedAllergy( - selectedAllergy: - items[index], - selectedAllergySeverity: - _selectedAllergySeverity, - remark: null, - isChecked: true); - widget.addAllergy( - mySelectedAllergy); - } - }); - }, - child: Column( + child: Expanded( + child: Column( + children: [ + Expanded( + child: Container( + height: MediaQuery.of(context).size.height * 0.70, + child: Center( + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: Column( + children: [ + TextFields( + hintText: widget.hintSearchText ?? + TranslationBase.of(context).selectAllergy, + borderWidth: 0.0, + padding: EdgeInsets.all(20), + borderRadius: 0, + suffixIcon: EvaIcons.search, + onChanged: (value) { + filterSearchResults(value); + }, + ), + SizedBox( + height: 10, + ), + Expanded( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Container( + height: MediaQuery.of(context).size.height * 0.60, + child: ListView.builder( + itemCount: items.length, + itemBuilder: (context, index) { + bool isSelected = + widget.isServiceSelected(items[index]); + MySelectedAllergy mySelectedAllergy; + if (isSelected) { + mySelectedAllergy = + widget.getServiceSelectedAllergy( + items[index]); + } + TextEditingController remarkController = + TextEditingController( + text: isSelected + ? mySelectedAllergy.remark + : null); + TextEditingController severityController = + TextEditingController( + text: isSelected + ? mySelectedAllergy + .selectedAllergySeverity != + null + ? projectViewModel.isArabic + ? mySelectedAllergy + .selectedAllergySeverity + .nameAr + : mySelectedAllergy + .selectedAllergySeverity + .nameEn + : null + : null); + return HeaderBodyExpandableNotifier( + headerWidget: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Row( children: [ Checkbox( - value: widget - .isServiceSelected( + value: + widget.isServiceSelected( items[index]), - activeColor: - Colors.red[800], + activeColor: Colors.red[800], onChanged: (bool newValue) { - // setState(() { - // if (widget - // .isServiceSelected(items[index])) { - // widget.removeHistory(items[index]); - // } else { - // widget.addHistory(items[index]); - // } - // }); + setState(() { + if (widget + .isServiceSelected( + items[index])) { + widget.removeAllergy( + items[index]); + } else { + MySelectedAllergy + mySelectedAllergy = + new MySelectedAllergy( + selectedAllergy: + items[index], + selectedAllergySeverity: + _selectedAllergySeverity, + remark: null, + isChecked: true, + isExpanded: true); + widget.addAllergy( + mySelectedAllergy); + } + }); }), - Expanded( + InkWell( + onTap: () { + setState(() { + if (widget + .isServiceSelected( + items[index])) { + widget.removeAllergy( + items[index]); + } else { + // TODO add Allergy + + MySelectedAllergy + mySelectedAllergy = + new MySelectedAllergy( + selectedAllergy: + items[index], + selectedAllergySeverity: + _selectedAllergySeverity, + remark: null, + isChecked: true, + isExpanded: true); + widget.addAllergy( + mySelectedAllergy); + } + }); + }, child: Padding( padding: const EdgeInsets .symmetric( horizontal: 10, vertical: 0), - child: AppText( - projectViewModel.isArabic - ? items[index] - .nameAr != - "" - ? items[index] - .nameAr - : items[index] - .nameEn - : items[index].nameEn, - color: Color(0xFF575757), - fontSize: 16, - fontWeight: - FontWeight.w600, + child: Container( + + child: AppText( + projectViewModel.isArabic + ? items[index] + .nameAr != + "" + ? items[index] + .nameAr + : items[index] + .nameEn + : items[index].nameEn, + color: Color(0xFF575757), + fontSize: 16, + fontWeight: + FontWeight.w600, + ), + width: MediaQuery.of(context).size.width * 0.55, ), ), ), ], ), - if(widget - .isServiceSelected( - items[index])) - Column(children: [ - TextFields( - onTapTextFields: widget.model - .allergySeverityList != - null - ? () { - MasterKeyDailog dialog = - MasterKeyDailog( - list: widget.model - .allergySeverityList, - okText: - TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { + InkWell( + onTap: () { + if (mySelectedAllergy != null) { + setState(() { + mySelectedAllergy + .isExpanded = mySelectedAllergy - .selectedAllergySeverity = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: - false, - context: context, - builder: (BuildContext - context) { - return dialog; - }, - ); + .isExpanded + ? false + : true; + }); } - : null, - hasLabelText: - mySelectedAllergy - .selectedAllergySeverity != - null - ? 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(isSubmitted && - mySelectedAllergy - .selectedAllergySeverity == null) - Row( + }, + child: Icon((mySelectedAllergy != + null + ? mySelectedAllergy + .isExpanded + : false) + ? EvaIcons + .arrowIosUpwardOutline + : EvaIcons + .arrowIosDownwardOutline)) + ], + ), + bodyWidget: Column( + children: [ + AppTextFieldCustom( + onClick: widget.model + .allergySeverityList != + null + ? () { + MasterKeyDailog dialog = + MasterKeyDailog( + list: widget.model + .allergySeverityList, + okText: + TranslationBase.of( + context) + .ok, + okFunction: + (selectedValue) { + setState(() { + mySelectedAllergy + .selectedAllergySeverity = + selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: + false, + context: context, + builder: (BuildContext + context) { + return dialog; + }, + ); + } + : null, + isDropDown: true, + hintText: + TranslationBase + .of(context) + .selectSeverity, + enabled: false, + maxLines: 2, + minLines: 2, + controller: severityController,), + SizedBox( + height: 5, + ), + if(isSubmitted && mySelectedAllergy !=null && + mySelectedAllergy + .selectedAllergySeverity == null) + Row( - children: [ - CustomValidationError(), - ], - mainAxisAlignment: MainAxisAlignment.start, - ), + children: [ + CustomValidationError(), + ], + mainAxisAlignment: MainAxisAlignment.start, + ), - SizedBox( - height: 10, - ), - Container( - margin: EdgeInsets.only( - left: 0, right: 0, top: 15), - child: TextFields( - hasLabelText: - remarkController.text != - '' - ? true - : false, - showLabelText: true, - hintText: TranslationBase - .of( - context) - .remarks, - fontSize: 13.5, - // hintColor: Colors.black, - fontWeight: FontWeight.w600, - maxLines: 25, - minLines: 10, - initialValue: isSelected - ? mySelectedAllergy - .remark : '', - // controller: remarkControlle + SizedBox( + height: 10, + ), + Container( + margin: EdgeInsets.only( + left: 0, right: 0, top: 15), + child: NewTextFields( + hintText: TranslationBase + .of( + context) + .remarks, + fontSize: 13.5, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + maxLines: 25, + minLines: 3, + initialValue: isSelected + ? mySelectedAllergy + .remark : '', + // controller: remarkControlle - onChanged: (value) { - if (isSelected) { - mySelectedAllergy - .remark = value; - }; - }, + onChanged: (value) { + if (isSelected) { + mySelectedAllergy + .remark = value; + } + }, - validator: (value) { - if (value == null) - return TranslationBase - .of( - context) - .emptyMessage; - else - return null; - }), - ), - SizedBox( - height: 10, - ), - ],) - ], - ), - ), - // DividerWithSpacesAround(), - ], - ); - }, + validator: (value) { + if (value == null) + return TranslationBase + .of( + context) + .emptyMessage; + else + return null; + }), + ), + SizedBox( + height: 10, + ), + ],), + isExpand: mySelectedAllergy != null + ? mySelectedAllergy.isExpanded + : false, + ); + }, + ), + ), ), ), - ), - ), - ], - ) - )), - ), - SizedBox( - height: 10, - ), - if (widget.model.state == ViewState.Idle) - AppButton( - title: "Add Selected Allergy", - padding: 10, - color: Color(0xFF359846), - onPressed: () { - setState(() { - isSubmitted = true; - }); - widget.addSelectedAllergy(); - }, + ], + ) + )), + ), + ), + SizedBox( + height: 10, ), - ], + if (widget.model.state == ViewState.Idle) + AppButton( + title: "Add Selected Allergy", + padding: 10, + color: Color(0xFF359846), + onPressed: () { + setState(() { + isSubmitted = true; + }); + widget.addSelectedAllergy(); + }, + ), + ], + ), ), ); }