From ac6a6e78552cf3d53e3a1a75f231942478f35a46 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 8 Jul 2021 17:31:46 +0300 Subject: [PATCH] keep show header in bottom sheet while it loading --- .../assessment/add_assessment_details.dart | 7 +- .../objective/add_examination_page.dart | 36 +-- .../objective/add_examination_widget.dart | 2 +- .../objective/examination_item_card.dart | 2 +- .../examinations_list_search_widget.dart | 6 +- .../objective/update_objective_page.dart | 7 +- .../bottom_sheet_title.dart | 5 +- .../subjective/allergies/add_allergies.dart | 174 +++++------ .../history/add_history_dialog.dart | 288 +++++++++--------- .../subjective/medication/add_medication.dart | 11 +- 10 files changed, 263 insertions(+), 275 deletions(-) diff --git a/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart b/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart index a30842f8..8b9cf7b8 100644 --- a/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart +++ b/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart @@ -32,6 +32,7 @@ class AddAssessmentDetails extends StatefulWidget { addSelectedAssessment; final PatiantInformtion patientInfo; final bool isUpdate; + AddAssessmentDetails( {Key key, this.mySelectedAssessment, @@ -129,14 +130,14 @@ class _AddAssessmentDetailsState extends State { }, builder: (_, model, w) => AppScaffold( baseViewModel: model, - isShowAppBar: false, + isShowAppBar: true, + appBar: BottomSheetTitle( + title: TranslationBase.of(context).addAssessmentDetails), backgroundColor: Theme.of(context).scaffoldBackgroundColor, body: SingleChildScrollView( child: Center( child: Column( children: [ - BottomSheetTitle( - title: TranslationBase.of(context).addAssessmentDetails), FractionallySizedBox( widthFactor: 0.9, child: Container( diff --git a/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart b/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart index 659de693..87af6ec2 100644 --- a/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart +++ b/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart @@ -4,6 +4,7 @@ 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_examination.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.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/app_texts_widget.dart'; @@ -38,39 +39,14 @@ class _AddExaminationPageState extends State { }, builder: (_, model, w) => AppScaffold( baseViewModel: model, - isShowAppBar: false, + isShowAppBar: true, + appBar: BottomSheetTitle( + title: "${TranslationBase.of(context).addExamination}", + ), backgroundColor: Color.fromRGBO(248, 248, 248, 1), body: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Container( - padding: EdgeInsets.only( - left: 16, top: 70, right: 16, bottom: 16), - color: Colors.white, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: AppText( - "${TranslationBase.of(context).addExamination}", - fontSize: SizeConfig.textMultiplier * 3.3, - color: Colors.black, - fontWeight: FontWeight.w700, - ), - ), - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Icon( - Icons.clear, - size: 40, - ), - ) - ], - ), - ), Expanded( child: SingleChildScrollView( child: Column( @@ -100,7 +76,7 @@ class _AddExaminationPageState extends State { widget.removeExamination(history); }); }, - addExamination: (selectedExamination) { + addHistory: (selectedExamination) { widget.mySelectedExamination .add(selectedExamination); // setState(() {}); diff --git a/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart b/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart index 5b5bfcb1..f0dc25cf 100644 --- a/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart +++ b/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart @@ -82,7 +82,7 @@ class _AddExaminationWidgetState extends State { onChanged: (newValue) { setState(() { if (widget.isServiceSelected(widget.item)) { - if (!examination.isLocal) + if (examination.isLocal) widget.removeExamination(widget.item); widget.expandClick(); } else { diff --git a/lib/screens/patients/profile/soap_update/objective/examination_item_card.dart b/lib/screens/patients/profile/soap_update/objective/examination_item_card.dart index 5116ac6b..84a4c740 100644 --- a/lib/screens/patients/profile/soap_update/objective/examination_item_card.dart +++ b/lib/screens/patients/profile/soap_update/objective/examination_item_card.dart @@ -60,7 +60,7 @@ class ExaminationItemCard extends StatelessWidget { SizedBox( height: 4, ), - if(examination.remark.isEmpty) + if(examination.remark.isNotEmpty) AppText( examination.remark, fontWeight: FontWeight.normal, diff --git a/lib/screens/patients/profile/soap_update/objective/examinations_list_search_widget.dart b/lib/screens/patients/profile/soap_update/objective/examinations_list_search_widget.dart index ef6ec056..c67102ee 100644 --- a/lib/screens/patients/profile/soap_update/objective/examinations_list_search_widget.dart +++ b/lib/screens/patients/profile/soap_update/objective/examinations_list_search_widget.dart @@ -9,14 +9,14 @@ import 'add_examination_widget.dart'; class ExaminationsListSearchWidget extends StatefulWidget { final Function(MasterKeyModel) removeExamination; - final Function(MySelectedExamination) addExamination; + final Function(MySelectedExamination) addHistory; final bool Function(MasterKeyModel) isServiceSelected; final List masterList; final List mySelectedExamination; ExaminationsListSearchWidget( {this.removeExamination, - this.addExamination, + this.addHistory, this.isServiceSelected, this.masterList, this.mySelectedExamination}); @@ -62,7 +62,7 @@ class _ExaminationsListSearchWidgetState ...items.mapIndexed((index, item) { return AddExaminationWidget( item: item, - addExamination: widget.addExamination, + addExamination: widget.addHistory, removeExamination: widget.removeExamination, mySelectedExamination: widget.mySelectedExamination, isServiceSelected: widget.isServiceSelected, diff --git a/lib/screens/patients/profile/soap_update/objective/update_objective_page.dart b/lib/screens/patients/profile/soap_update/objective/update_objective_page.dart index bd6cd39d..dbd3b080 100644 --- a/lib/screens/patients/profile/soap_update/objective/update_objective_page.dart +++ b/lib/screens/patients/profile/soap_update/objective/update_objective_page.dart @@ -260,11 +260,8 @@ class _UpdateObjectivePageState extends State { widget.changeLoadingState(false); Helpers.showErrorToast(model.error); } else { - widget.changeLoadingState(false); - // TODO Elham* return this - // widget.changeLoadingState(true); - - //widget.changePageViewIndex(2); + widget.changeLoadingState(true); + widget.changePageViewIndex(2); } } else { Helpers.showErrorToast(TranslationBase.of(context).examinationErrorMsg); diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart index 8f5ecf93..d8110844 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart @@ -1,7 +1,7 @@ import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:flutter/material.dart'; -class BottomSheetTitle extends StatelessWidget { +class BottomSheetTitle extends StatelessWidget with PreferredSizeWidget { const BottomSheetTitle({ Key key, this.title, }) : super(key: key); @@ -57,4 +57,7 @@ class BottomSheetTitle extends StatelessWidget { ), ); } + + @override + Size get preferredSize => Size(double.maxFinite,115); } diff --git a/lib/screens/patients/profile/soap_update/subjective/allergies/add_allergies.dart b/lib/screens/patients/profile/soap_update/subjective/allergies/add_allergies.dart index fc7329e5..083c8743 100644 --- a/lib/screens/patients/profile/soap_update/subjective/allergies/add_allergies.dart +++ b/lib/screens/patients/profile/soap_update/subjective/allergies/add_allergies.dart @@ -1,5 +1,6 @@ import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.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_allergy.dart'; @@ -83,95 +84,100 @@ class _AddAllergiesState extends State { } }, builder: (_, model, w) => AppScaffold( - baseViewModel: model, - isShowAppBar: false, - body: Center( - child: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - BottomSheetTitle( - title: TranslationBase.of(context).addAllergies, + baseViewModel: model, + isShowAppBar: true, + appBar: BottomSheetTitle( + title: TranslationBase.of(context).addAllergies, + ), + body: Center( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 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), + ), + ), + ), + ), ), + ), + SizedBox( + height: MediaQuery.of(context).size.height * 0.11, + ), + ]), + ), + ), + bottomSheet: model.state == ViewState.Busy + ? Container( + height: 0, + ) + : Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(0.0), + ), + border: Border.all(color: HexColor('#707070'), width: 0), + ), + height: MediaQuery.of(context).size.height * 0.1, + width: double.infinity, + child: Column( + children: [ 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), - ), - ), + Container( + child: FractionallySizedBox( + widthFactor: .80, + child: Center( + child: AppButton( + title: TranslationBase.of(context).addAllergies, + padding: 10, + color: Color(0xFF359846), + onPressed: () { + widget.addAllergiesFun(myAllergiesListLocal); + }, ), ), ), ), SizedBox( - height: MediaQuery.of(context).size.height * 0.11, + height: 5, ), - ]), - ), - ),bottomSheet: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(0.0), - ), - border: Border.all(color: HexColor('#707070'), width: 0), - ), - 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).addAllergies, - padding: 10, - color: Color(0xFF359846), - onPressed: () { - widget.addAllergiesFun(myAllergiesListLocal); - }, - ), + ], ), ), - ), - SizedBox( - height: 5, - ), - ], - ), - ),), + ), ), ); } @@ -207,17 +213,15 @@ class _AddAllergiesState extends State { addAllergyLocally(MySelectedAllergy mySelectedAllergy) { if (mySelectedAllergy.selectedAllergy == null) { - Helpers.showErrorToast(TranslationBase - .of(context) - .requiredMsg); + Helpers.showErrorToast(TranslationBase.of(context).requiredMsg); } else { setState(() { List allergy = - // ignore: missing_return - myAllergiesListLocal - .where((element) => - mySelectedAllergy.selectedAllergy.id == - element.selectedAllergy.id) + // ignore: missing_return + myAllergiesListLocal + .where((element) => + mySelectedAllergy.selectedAllergy.id == + element.selectedAllergy.id) .toList(); if (allergy.isEmpty) { diff --git a/lib/screens/patients/profile/soap_update/subjective/history/add_history_dialog.dart b/lib/screens/patients/profile/soap_update/subjective/history/add_history_dialog.dart index 1da8db17..bd2f8502 100644 --- a/lib/screens/patients/profile/soap_update/subjective/history/add_history_dialog.dart +++ b/lib/screens/patients/profile/soap_update/subjective/history/add_history_dialog.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.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'; @@ -19,10 +20,15 @@ class AddHistoryDialog extends StatefulWidget { final PageController controller; final List myHistoryList; final Function addSelectedHistories; - final Function (MasterKeyModel) removeHistory; + final Function(MasterKeyModel) removeHistory; const AddHistoryDialog( - {Key key, this.changePageViewIndex, this.controller, this.myHistoryList, this.addSelectedHistories, this.removeHistory}) + {Key key, + this.changePageViewIndex, + this.controller, + this.myHistoryList, + this.addSelectedHistories, + this.removeHistory}) : super(key: key); @override @@ -51,96 +57,96 @@ class _AddHistoryDialogState extends State { }, builder: (_, model, w) => AppScaffold( baseViewModel: model, - isShowAppBar: false, + isShowAppBar: true, + appBar: BottomSheetTitle( + title: TranslationBase.of(context).addHistory), 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(() { - }); - }, - 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(); - }, + children: [ + 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(() {}); + }, + 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), ), @@ -149,59 +155,63 @@ class _AddHistoryDialogState extends State { ), ), ), - SizedBox(height:MediaQuery.of(context).size.height * 0.11 ,) + SizedBox( + height: MediaQuery.of(context).size.height * 0.11, + ) ], - ) - ), + )), ), - bottomSheet: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(0.0), - ), - border: Border.all(color: HexColor('#707070'), width: 0), - ), - 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).addSelectedHistories, - padding: 10, - color: Color(0xFF359846), - onPressed: () { - widget.addSelectedHistories(); - }, - ), + bottomSheet: model.state == ViewState.Busy + ? Container( + height: 0, + ) + : Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(0.0), ), + border: Border.all(color: HexColor('#707070'), width: 0), + ), + 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) + .addSelectedHistories, + padding: 10, + color: Color(0xFF359846), + onPressed: () { + widget.addSelectedHistories(); + }, + ), + ), + ), + ), + SizedBox( + height: 5, + ), + ], ), ), - SizedBox( - height: 5, - ), - ], - ), - ), ), )); } createAndAddHistory(MasterKeyModel history) { - List myhistory = widget.myHistoryList.where((element) => - history.id == - element.selectedHistory.id && - history.typeId == - element.selectedHistory.typeId - ).toList(); + List myhistory = widget.myHistoryList + .where((element) => + history.id == element.selectedHistory.id && + history.typeId == element.selectedHistory.typeId) + .toList(); if (myhistory.isEmpty) { setState(() { @@ -217,18 +227,14 @@ class _AddHistoryDialogState extends State { } isServiceSelected(MasterKeyModel masterKey) { - Iterable history = - widget - .myHistoryList - .where((element) => - masterKey.id == element.selectedHistory.id && - masterKey.typeId == element.selectedHistory.typeId && - element.isChecked); + 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/screens/patients/profile/soap_update/subjective/medication/add_medication.dart b/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart index 69475926..d7f8f6ed 100644 --- a/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart +++ b/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart @@ -1,6 +1,7 @@ // 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/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/search_drug/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'; @@ -74,15 +75,15 @@ class _AddMedicationState extends State { }, builder: (_, model, w) => AppScaffold( baseViewModel: model, - isShowAppBar: false, + isShowAppBar: true, + appBar: BottomSheetTitle( + title: TranslationBase.of(context).addMedication, + ), body: Center( child: Container( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - BottomSheetTitle( - title: TranslationBase.of(context).addMedication, - ), SizedBox( height: 10, ), @@ -381,7 +382,7 @@ class _AddMedicationState extends State { ]), ), ), - bottomSheet: Container( + bottomSheet:model.state == ViewState.Busy?Container(height: 0,): Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(