From 9317173c052c912b0010901325760b10a8c8b009 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 9 Sep 2021 11:03:43 +0300 Subject: [PATCH 1/6] add filtration on level of clinic --- .../viewModel/PatientSearchViewModel.dart | 120 +++++++++++++----- .../In_patient/in_patient_list_page.dart | 28 ++-- 2 files changed, 103 insertions(+), 45 deletions(-) diff --git a/lib/core/viewModel/PatientSearchViewModel.dart b/lib/core/viewModel/PatientSearchViewModel.dart index 43d8b221..07975bc3 100644 --- a/lib/core/viewModel/PatientSearchViewModel.dart +++ b/lib/core/viewModel/PatientSearchViewModel.dart @@ -186,30 +186,48 @@ class PatientSearchViewModel extends BaseViewModel { } } else { setDefaultInPatientList(); - generateMyInpatientClinicList(); setState(ViewState.Idle); } } - sortInPatient({bool isDes = false}) { - if (isDes) - filteredInPatientItems.sort((PatiantInformtion a, PatiantInformtion b) => - b.admissionDateWithDateTimeForm - .compareTo(a.admissionDateWithDateTimeForm)); - else - filteredInPatientItems.sort((PatiantInformtion a, PatiantInformtion b) => - a.admissionDateWithDateTimeForm - .compareTo(b.admissionDateWithDateTimeForm)); + sortInPatient({bool isDes = false, bool isAllClinic}) { + if (isAllClinic + ? inPatientList.length > 0 + : filteredInPatientItems.length > 0) { + List localInPatient = + isAllClinic ? [...inPatientList] : [...filteredInPatientItems]; + if (isDes) + localInPatient.sort((PatiantInformtion a, PatiantInformtion b) => b + .admissionDateWithDateTimeForm + .compareTo(a.admissionDateWithDateTimeForm)); + else + localInPatient.sort((PatiantInformtion a, PatiantInformtion b) => a + .admissionDateWithDateTimeForm + .compareTo(b.admissionDateWithDateTimeForm)); + + if (isAllClinic) { + resetInPatientPagination(); + filteredInPatientItems + .addAll(localInPatient.sublist(firstSubsetIndex, lastSubsetIndex)); + } else { + filteredInPatientItems.clear(); + filteredInPatientItems.addAll(localInPatient); + } + } setState(ViewState.Idle); } - Future setDefaultInPatientList() async { - setState(ViewState.BusyLocal); - await getDoctorProfile(); + resetInPatientPagination() { filteredInPatientItems.clear(); firstSubsetIndex = 0; lastSubsetIndex = inPatientPageSize - 1; + } + + Future setDefaultInPatientList() async { + setState(ViewState.BusyLocal); + await getDoctorProfile(); + resetInPatientPagination(); if (inPatientList.length > 0) filteredInPatientItems .addAll(inPatientList.sublist(firstSubsetIndex, lastSubsetIndex)); @@ -218,7 +236,7 @@ class PatientSearchViewModel extends BaseViewModel { generateMyInpatientClinicList() { inPatientList.forEach((element) { - if(!myInpatientClinicList.contains(element.clinicDescription)) { + if (!myInpatientClinicList.contains(element.clinicDescription)) { myInpatientClinicList.add(element.clinicDescription); } }); @@ -240,8 +258,7 @@ class PatientSearchViewModel extends BaseViewModel { } } - - filterByHospital({ int hospitalId}) { + filterByHospital({int hospitalId}) { filteredInPatientItems = []; for (var i = 0; i < inPatientList.length; i++) { if (inPatientList[i].projectId == hospitalId) { @@ -251,7 +268,7 @@ class PatientSearchViewModel extends BaseViewModel { notifyListeners(); } - filterByClinic({ String clinicName}) { + filterByClinic({String clinicName}) { filteredInPatientItems = []; for (var i = 0; i < inPatientList.length; i++) { if (inPatientList[i].clinicDescription == clinicName) { @@ -266,28 +283,61 @@ class PatientSearchViewModel extends BaseViewModel { _inPatientService.myInPatientList = []; } - void filterSearchResults(String query) { + void filterSearchResults(String query, {bool isAllClinic}) { var strExist = query.length > 0 ? true : false; - if (strExist) { - filteredInPatientItems = []; - for (var i = 0; i < inPatientList.length; i++) { - String firstName = inPatientList[i].firstName.toUpperCase(); - String lastName = inPatientList[i].lastName.toUpperCase(); - String mobile = inPatientList[i].mobileNumber.toUpperCase(); - String patientID = inPatientList[i].patientId.toString(); - - if (firstName.contains(query.toUpperCase()) || - lastName.contains(query.toUpperCase()) || - mobile.contains(query) || - patientID.contains(query)) { - filteredInPatientItems.add(inPatientList[i]); + if (isAllClinic) { + if (strExist) { + filteredInPatientItems = []; + for (var i = 0; i < inPatientList.length; i++) { + String firstName = inPatientList[i].firstName.toUpperCase(); + String lastName = inPatientList[i].lastName.toUpperCase(); + String mobile = inPatientList[i].mobileNumber.toUpperCase(); + String patientID = inPatientList[i].patientId.toString(); + + if (firstName.contains(query.toUpperCase()) || + lastName.contains(query.toUpperCase()) || + mobile.contains(query) || + patientID.contains(query)) { + filteredInPatientItems.add(inPatientList[i]); + } } + notifyListeners(); + } else { + if (inPatientList.length > 0) filteredInPatientItems.clear(); + filteredInPatientItems.addAll(inPatientList); + notifyListeners(); } - notifyListeners(); } else { - if (inPatientList.length > 0) filteredInPatientItems.clear(); - filteredInPatientItems.addAll(inPatientList); - notifyListeners(); + List localFilteredInPatientItems = [ + ...filteredInPatientItems + ]; + + if (strExist) { + filteredInPatientItems.clear(); + for (var i = 0; i < localFilteredInPatientItems.length; i++) { + String firstName = + localFilteredInPatientItems[i].firstName.toUpperCase(); + String lastName = + localFilteredInPatientItems[i].lastName.toUpperCase(); + String mobile = + localFilteredInPatientItems[i].mobileNumber.toUpperCase(); + String patientID = + localFilteredInPatientItems[i].patientId.toString(); + + if (firstName.contains(query.toUpperCase()) || + lastName.contains(query.toUpperCase()) || + mobile.contains(query) || + patientID.contains(query)) { + filteredInPatientItems.add(localFilteredInPatientItems[i]); + } + } + notifyListeners(); + } else { + if (localFilteredInPatientItems.length > 0) + filteredInPatientItems.clear(); + filteredInPatientItems.addAll(localFilteredInPatientItems); + notifyListeners(); + } } } diff --git a/lib/screens/patients/In_patient/in_patient_list_page.dart b/lib/screens/patients/In_patient/in_patient_list_page.dart index 80acb88d..f52b4819 100644 --- a/lib/screens/patients/In_patient/in_patient_list_page.dart +++ b/lib/screens/patients/In_patient/in_patient_list_page.dart @@ -30,6 +30,7 @@ class _InPatientListPageState extends State { bool isSortDes = false; bool isAllClinic = true; + bool hasQuery = false; bool showBottomSheet = false; String selectedClinicName; @@ -47,11 +48,8 @@ class _InPatientListPageState extends State { body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Container( - // height: MediaQuery.of(context).size.height * 0.070, - // ), Container( - margin: EdgeInsets.symmetric(horizontal: 14.0, vertical: 10), + margin: EdgeInsets.only(left: 10.0,right: 10, top: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -73,7 +71,10 @@ class _InPatientListPageState extends State { }, activeColor: Colors.red, ), - AppText("All Clinic", fontSize: 15,), + AppText( + "All Clinic", + fontSize: 15, + ), ], ), onTap: () { @@ -106,7 +107,10 @@ class _InPatientListPageState extends State { }, activeColor: Colors.red, ), - AppText(selectedClinicName ?? "Select Clinic", fontSize: 15,), + AppText( + selectedClinicName ?? "Select Clinic", + fontSize: 15, + ), Container( margin: EdgeInsets.only(bottom: 10), child: Icon(FontAwesomeIcons.sortDown)) @@ -116,7 +120,7 @@ class _InPatientListPageState extends State { ), ), Container( - margin: EdgeInsets.all(16.0), + margin: EdgeInsets.only(left: 16, right: 16, bottom: 16, top:5), child: Stack( children: [ AppTextFieldCustom( @@ -131,7 +135,11 @@ class _InPatientListPageState extends State { ), controller: _searchController, onChanged: (value) { - widget.patientSearchViewModel.filterSearchResults(value); + setState(() { + hasQuery = true; + }); + widget.patientSearchViewModel + .filterSearchResults(value, isAllClinic: isAllClinic); }), Positioned( right: 35, @@ -148,7 +156,7 @@ class _InPatientListPageState extends State { onPressed: () { GifLoaderDialogUtils.showMyDialog(context); widget.patientSearchViewModel - .sortInPatient(isDes: isSortDes); + .sortInPatient(isDes: isSortDes, isAllClinic:isAllClinic); isSortDes = !isSortDes; GifLoaderDialogUtils.hideDialog(context); }, @@ -277,7 +285,7 @@ class _InPatientListPageState extends State { return SizedBox(); }), onNotification: (t) { - if (isAllClinic) if (t + if (isAllClinic && !hasQuery) if (t is ScrollUpdateNotification && t.metrics.pixels >= t.metrics.maxScrollExtent - 50) { From a1f972909134bc57b86408fc7728005380e3c1ef Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 9 Sep 2021 11:48:44 +0300 Subject: [PATCH 2/6] in patient list improve performace --- .../viewModel/PatientSearchViewModel.dart | 8 ++++ .../In_patient/in_patient_list_page.dart | 27 +++++++---- .../patients/patient_card/PatientCard.dart | 48 ++++++++++++------- 3 files changed, 56 insertions(+), 27 deletions(-) diff --git a/lib/core/viewModel/PatientSearchViewModel.dart b/lib/core/viewModel/PatientSearchViewModel.dart index 07975bc3..0333f7df 100644 --- a/lib/core/viewModel/PatientSearchViewModel.dart +++ b/lib/core/viewModel/PatientSearchViewModel.dart @@ -258,6 +258,14 @@ class PatientSearchViewModel extends BaseViewModel { } } + removeOnFilteredList() { + if (lastSubsetIndex-inPatientPageSize - 1 > 0) { + filteredInPatientItems + .removeAt(lastSubsetIndex-inPatientPageSize - 1); + setState(ViewState.Idle); + } + } + filterByHospital({int hospitalId}) { filteredInPatientItems = []; for (var i = 0; i < inPatientList.length; i++) { diff --git a/lib/screens/patients/In_patient/in_patient_list_page.dart b/lib/screens/patients/In_patient/in_patient_list_page.dart index f52b4819..9106de0f 100644 --- a/lib/screens/patients/In_patient/in_patient_list_page.dart +++ b/lib/screens/patients/In_patient/in_patient_list_page.dart @@ -48,8 +48,9 @@ class _InPatientListPageState extends State { body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ + if(!widget.isMyInPatient) Container( - margin: EdgeInsets.only(left: 10.0,right: 10, top: 10), + margin: EdgeInsets.only(left: 10.0, right: 10, top: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -120,7 +121,7 @@ class _InPatientListPageState extends State { ), ), Container( - margin: EdgeInsets.only(left: 16, right: 16, bottom: 16, top:5), + margin: EdgeInsets.only(left: 16, right: 16, bottom: 16, top: 5), child: Stack( children: [ AppTextFieldCustom( @@ -155,8 +156,8 @@ class _InPatientListPageState extends State { // padding: EdgeInsets.only(bottom: 30), onPressed: () { GifLoaderDialogUtils.showMyDialog(context); - widget.patientSearchViewModel - .sortInPatient(isDes: isSortDes, isAllClinic:isAllClinic); + widget.patientSearchViewModel.sortInPatient( + isDes: isSortDes, isAllClinic: isAllClinic); isSortDes = !isSortDes; GifLoaderDialogUtils.hideDialog(context); }, @@ -286,11 +287,19 @@ class _InPatientListPageState extends State { }), onNotification: (t) { if (isAllClinic && !hasQuery) if (t - is ScrollUpdateNotification && - t.metrics.pixels >= - t.metrics.maxScrollExtent - 50) { - widget.patientSearchViewModel - .addOnFilteredList(); + is ScrollUpdateNotification) { + if (t.metrics.pixels >= + t.metrics.maxScrollExtent - 50) { + widget.patientSearchViewModel + .addOnFilteredList(); + } + + if (t.metrics.pixels <= + t.metrics.minScrollExtent - 50) { + widget.patientSearchViewModel + .removeOnFilteredList(); + } + } return; }, diff --git a/lib/widgets/patients/patient_card/PatientCard.dart b/lib/widgets/patients/patient_card/PatientCard.dart index efc85f18..c5200c75 100644 --- a/lib/widgets/patients/patient_card/PatientCard.dart +++ b/lib/widgets/patients/patient_card/PatientCard.dart @@ -349,21 +349,22 @@ class PatientCard extends StatelessWidget { ), Expanded( child: Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ CustomRow( - label: TranslationBase.of(context).fileNumber, + label: + TranslationBase.of(context).fileNumber, value: patientInfo.patientId.toString(), ), CustomRow( - label: TranslationBase.of(context).age + " : ", + label: + TranslationBase.of(context).age + " : ", value: "${AppDateUtils.getAgeByBirthday(patientInfo.dateofBirth, context, isServerFormat: !isFromLiveCare)}", ), - if (isInpatient) CustomRow( label: patientInfo.admissionDate == null @@ -377,33 +378,46 @@ class PatientCard extends StatelessWidget { ), if (patientInfo.admissionDate != null) CustomRow( - label: TranslationBase.of(context).numOfDays + + label: TranslationBase.of(context) + .numOfDays + " : ", value: "${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patientInfo.admissionDate)).inDays + 1}", ), + if (patientInfo.admissionDate != null) + CustomRow( + // TODO Elham* add translation + label: + "Clinic Name" + + " : ", + value: "${patientInfo.clinicDescription}", + ), if (patientInfo.admissionDate != null) CustomRow( label: - TranslationBase.of(context).roomNo + " : ", + TranslationBase.of(context).roomNo + + " : ", value: "${patientInfo.roomId}", ), - if (isFromLiveCare) Column( children: [ CustomRow( - label: TranslationBase.of(context).clinic + + label: TranslationBase.of(context) + .clinic + " : ", value: patientInfo.clinicName, ), ], ), ]), - ), - Icon(Icons.arrow_forward, size: 24,), - ], - )) + ), + Icon( + Icons.arrow_forward, + size: 24, + ), + ], + )) ]), isFromLiveCare ? Row( @@ -458,5 +472,3 @@ class PatientCard extends StatelessWidget { )); } } - - From 37cd34f5687857d659e0fa0d57ad5a2940b68a28 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 9 Sep 2021 12:10:49 +0300 Subject: [PATCH 3/6] move no data widget to separate file --- lib/screens/patients/In_patient/NoData.dart | 20 +++++++++++++++++ .../In_patient/in_patient_list_page.dart | 22 +++++-------------- 2 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 lib/screens/patients/In_patient/NoData.dart diff --git a/lib/screens/patients/In_patient/NoData.dart b/lib/screens/patients/In_patient/NoData.dart new file mode 100644 index 00000000..0c48cd2a --- /dev/null +++ b/lib/screens/patients/In_patient/NoData.dart @@ -0,0 +1,20 @@ +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; +import 'package:flutter/material.dart'; + +class NoData extends StatelessWidget { + const NoData({ + Key key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Expanded( + child: SingleChildScrollView( + child: Container( + child: ErrorMessage( + error: TranslationBase.of(context).noDataAvailable)), + ), + ); + } +} \ No newline at end of file diff --git a/lib/screens/patients/In_patient/in_patient_list_page.dart b/lib/screens/patients/In_patient/in_patient_list_page.dart index 9106de0f..152d87db 100644 --- a/lib/screens/patients/In_patient/in_patient_list_page.dart +++ b/lib/screens/patients/In_patient/in_patient_list_page.dart @@ -14,6 +14,7 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import '../../../routes.dart'; +import 'NoData.dart'; class InPatientListPage extends StatefulWidget { final bool isMyInPatient; @@ -90,6 +91,7 @@ class _InPatientListPageState extends State { onTap: () { setState(() { isAllClinic = false; + if(widget.patientSearchViewModel.myInpatientClinicList.length > 0) showBottomSheet = true; }); }, @@ -102,7 +104,8 @@ class _InPatientListPageState extends State { setState(() { setState(() { isAllClinic = false; - showBottomSheet = true; + if(widget.patientSearchViewModel.myInpatientClinicList.length > 0) + showBottomSheet = true; }); }); }, @@ -320,7 +323,7 @@ class _InPatientListPageState extends State { height: 0, ) : Container( - height: 500, + height: MediaQuery.of(context).size.height * 0.5, color: Colors.white, child: ListView.builder( itemCount: widget @@ -369,19 +372,4 @@ class _InPatientListPageState extends State { } } -class NoData extends StatelessWidget { - const NoData({ - Key key, - }) : super(key: key); - @override - Widget build(BuildContext context) { - return Expanded( - child: SingleChildScrollView( - child: Container( - child: ErrorMessage( - error: TranslationBase.of(context).noDataAvailable)), - ), - ); - } -} From ce199f7d9860ad6d7ad4c0f8966efce0256c5fad Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 9 Sep 2021 15:07:18 +0300 Subject: [PATCH 4/6] separate in patient and my in patient to 2 files --- .../viewModel/PatientSearchViewModel.dart | 151 ++++++--- .../In_patient/in_patient_list_page.dart | 307 ++++++------------ .../In_patient/list_of_all_in_patient.dart | 124 +++++++ .../In_patient/list_of_my_inpatient.dart | 76 +++++ 4 files changed, 392 insertions(+), 266 deletions(-) create mode 100644 lib/screens/patients/In_patient/list_of_all_in_patient.dart create mode 100644 lib/screens/patients/In_patient/list_of_my_inpatient.dart diff --git a/lib/core/viewModel/PatientSearchViewModel.dart b/lib/core/viewModel/PatientSearchViewModel.dart index 0333f7df..84fe8b44 100644 --- a/lib/core/viewModel/PatientSearchViewModel.dart +++ b/lib/core/viewModel/PatientSearchViewModel.dart @@ -30,9 +30,9 @@ class PatientSearchViewModel extends BaseViewModel { int firstSubsetIndex = 0; int inPatientPageSize = 20; - int lastSubsetIndex = 19; + int lastSubsetIndex = 20; - List myInpatientClinicList = []; + List InpatientClinicList = []; searchData(String str) { var strExist = str.length > 0 ? true : false; @@ -88,10 +88,8 @@ class PatientSearchViewModel extends BaseViewModel { sortOutPatient({bool isDes = false}) { if (isDes) filterData = filterData.reversed.toList(); - // filterData.sort((PatiantInformtion a, PatiantInformtion b)=>b.appointmentDateWithDateTimeForm.compareTo(a.appointmentDateWithDateTimeForm)); else filterData = filterData.reversed.toList(); - // filterData.sort((PatiantInformtion a, PatiantInformtion b)=>a.appointmentDateWithDateTimeForm.compareTo(b.appointmentDateWithDateTimeForm)); setState(ViewState.Idle); } @@ -166,6 +164,7 @@ class PatientSearchViewModel extends BaseViewModel { _inPatientService.myInPatientList; List filteredInPatientItems = List(); + List filteredMyInPatientItems = List(); Future getInPatientList(PatientSearchRequestModel requestModel, {bool isMyInpatient = false, bool isLocalBusy = false}) async { @@ -186,17 +185,22 @@ class PatientSearchViewModel extends BaseViewModel { } } else { setDefaultInPatientList(); - generateMyInpatientClinicList(); + generateInpatientClinicList(); setState(ViewState.Idle); } } - sortInPatient({bool isDes = false, bool isAllClinic}) { - if (isAllClinic - ? inPatientList.length > 0 - : filteredInPatientItems.length > 0) { - List localInPatient = - isAllClinic ? [...inPatientList] : [...filteredInPatientItems]; + sortInPatient({bool isDes = false, bool isAllClinic, bool isMyInPatient}) { + if (isMyInPatient + ? myIinPatientList.length > 0 + : isAllClinic + ? inPatientList.length > 0 + : filteredInPatientItems.length > 0) { + List localInPatient = isMyInPatient + ? [...filteredMyInPatientItems] + : isAllClinic + ? [...inPatientList] + : [...filteredInPatientItems]; if (isDes) localInPatient.sort((PatiantInformtion a, PatiantInformtion b) => b .admissionDateWithDateTimeForm @@ -205,8 +209,10 @@ class PatientSearchViewModel extends BaseViewModel { localInPatient.sort((PatiantInformtion a, PatiantInformtion b) => a .admissionDateWithDateTimeForm .compareTo(b.admissionDateWithDateTimeForm)); - - if (isAllClinic) { + if (isMyInPatient) { + filteredMyInPatientItems.clear(); + filteredMyInPatientItems.addAll(localInPatient); + } else if (isAllClinic) { resetInPatientPagination(); filteredInPatientItems .addAll(localInPatient.sublist(firstSubsetIndex, lastSubsetIndex)); @@ -231,13 +237,17 @@ class PatientSearchViewModel extends BaseViewModel { if (inPatientList.length > 0) filteredInPatientItems .addAll(inPatientList.sublist(firstSubsetIndex, lastSubsetIndex)); + + if (myIinPatientList.length > 0) { + filteredMyInPatientItems.addAll(myIinPatientList); + } setState(ViewState.Idle); } - generateMyInpatientClinicList() { + generateInpatientClinicList() { inPatientList.forEach((element) { - if (!myInpatientClinicList.contains(element.clinicDescription)) { - myInpatientClinicList.add(element.clinicDescription); + if (!InpatientClinicList.contains(element.clinicDescription)) { + InpatientClinicList.add(element.clinicDescription); } }); } @@ -259,9 +269,8 @@ class PatientSearchViewModel extends BaseViewModel { } removeOnFilteredList() { - if (lastSubsetIndex-inPatientPageSize - 1 > 0) { - filteredInPatientItems - .removeAt(lastSubsetIndex-inPatientPageSize - 1); + if (lastSubsetIndex - inPatientPageSize - 1 > 0) { + filteredInPatientItems.removeAt(lastSubsetIndex - inPatientPageSize - 1); setState(ViewState.Idle); } } @@ -291,61 +300,95 @@ class PatientSearchViewModel extends BaseViewModel { _inPatientService.myInPatientList = []; } - void filterSearchResults(String query, {bool isAllClinic}) { + void filterSearchResults(String query, + {bool isAllClinic, bool isMyInPatient}) { var strExist = query.length > 0 ? true : false; - if (isAllClinic) { - if (strExist) { - filteredInPatientItems = []; - for (var i = 0; i < inPatientList.length; i++) { - String firstName = inPatientList[i].firstName.toUpperCase(); - String lastName = inPatientList[i].lastName.toUpperCase(); - String mobile = inPatientList[i].mobileNumber.toUpperCase(); - String patientID = inPatientList[i].patientId.toString(); - if (firstName.contains(query.toUpperCase()) || - lastName.contains(query.toUpperCase()) || - mobile.contains(query) || - patientID.contains(query)) { - filteredInPatientItems.add(inPatientList[i]); - } - } - notifyListeners(); - } else { - if (inPatientList.length > 0) filteredInPatientItems.clear(); - filteredInPatientItems.addAll(inPatientList); - notifyListeners(); - } - } else { - List localFilteredInPatientItems = [ - ...filteredInPatientItems + if (isMyInPatient) { + List localFilteredMyInPatientItems = [ + ...myIinPatientList ]; if (strExist) { - filteredInPatientItems.clear(); - for (var i = 0; i < localFilteredInPatientItems.length; i++) { + filteredMyInPatientItems.clear(); + for (var i = 0; i < localFilteredMyInPatientItems.length; i++) { String firstName = - localFilteredInPatientItems[i].firstName.toUpperCase(); + localFilteredMyInPatientItems[i].firstName.toUpperCase(); String lastName = - localFilteredInPatientItems[i].lastName.toUpperCase(); + localFilteredMyInPatientItems[i].lastName.toUpperCase(); String mobile = - localFilteredInPatientItems[i].mobileNumber.toUpperCase(); + localFilteredMyInPatientItems[i].mobileNumber.toUpperCase(); String patientID = - localFilteredInPatientItems[i].patientId.toString(); + localFilteredMyInPatientItems[i].patientId.toString(); if (firstName.contains(query.toUpperCase()) || lastName.contains(query.toUpperCase()) || mobile.contains(query) || patientID.contains(query)) { - filteredInPatientItems.add(localFilteredInPatientItems[i]); + filteredMyInPatientItems.add(localFilteredMyInPatientItems[i]); } } notifyListeners(); } else { - if (localFilteredInPatientItems.length > 0) - filteredInPatientItems.clear(); - filteredInPatientItems.addAll(localFilteredInPatientItems); + if (myIinPatientList.length > 0) filteredMyInPatientItems.clear(); + filteredMyInPatientItems.addAll(myIinPatientList); notifyListeners(); } + } else { + if (isAllClinic) { + if (strExist) { + filteredInPatientItems = []; + for (var i = 0; i < inPatientList.length; i++) { + String firstName = inPatientList[i].firstName.toUpperCase(); + String lastName = inPatientList[i].lastName.toUpperCase(); + String mobile = inPatientList[i].mobileNumber.toUpperCase(); + String patientID = inPatientList[i].patientId.toString(); + + if (firstName.contains(query.toUpperCase()) || + lastName.contains(query.toUpperCase()) || + mobile.contains(query) || + patientID.contains(query)) { + filteredInPatientItems.add(inPatientList[i]); + } + } + notifyListeners(); + } else { + if (inPatientList.length > 0) filteredInPatientItems.clear(); + filteredInPatientItems.addAll(inPatientList); + notifyListeners(); + } + } else { + List localFilteredInPatientItems = [ + ...filteredInPatientItems + ]; + + if (strExist) { + filteredInPatientItems.clear(); + for (var i = 0; i < localFilteredInPatientItems.length; i++) { + String firstName = + localFilteredInPatientItems[i].firstName.toUpperCase(); + String lastName = + localFilteredInPatientItems[i].lastName.toUpperCase(); + String mobile = + localFilteredInPatientItems[i].mobileNumber.toUpperCase(); + String patientID = + localFilteredInPatientItems[i].patientId.toString(); + + if (firstName.contains(query.toUpperCase()) || + lastName.contains(query.toUpperCase()) || + mobile.contains(query) || + patientID.contains(query)) { + filteredInPatientItems.add(localFilteredInPatientItems[i]); + } + } + notifyListeners(); + } else { + if (localFilteredInPatientItems.length > 0) + filteredInPatientItems.clear(); + filteredInPatientItems.addAll(localFilteredInPatientItems); + notifyListeners(); + } + } } } diff --git a/lib/screens/patients/In_patient/in_patient_list_page.dart b/lib/screens/patients/In_patient/in_patient_list_page.dart index 152d87db..cb3d4856 100644 --- a/lib/screens/patients/In_patient/in_patient_list_page.dart +++ b/lib/screens/patients/In_patient/in_patient_list_page.dart @@ -1,20 +1,16 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.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/patient_card/PatientCard.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_loader_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/errors/error_message.dart'; -import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_container.dart'; import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import '../../../routes.dart'; import 'NoData.dart'; +import 'list_of_all_in_patient.dart'; +import 'list_of_my_inpatient.dart'; class InPatientListPage extends StatefulWidget { final bool isMyInPatient; @@ -49,82 +45,88 @@ class _InPatientListPageState extends State { body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - if(!widget.isMyInPatient) - Container( - margin: EdgeInsets.only(left: 10.0, right: 10, top: 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Row( - children: [ - Radio( - value: 1, - groupValue: isAllClinic ? 1 : 2, - onChanged: (value) { - setState(() { - setState(() { - isAllClinic = true; - showBottomSheet = false; - }); - widget.patientSearchViewModel - .setDefaultInPatientList(); - }); - }, - activeColor: Colors.red, - ), - AppText( - "All Clinic", - fontSize: 15, - ), - ], - ), - onTap: () { - setState(() { - isAllClinic = true; - showBottomSheet = false; - }); - widget.patientSearchViewModel.setDefaultInPatientList(); - }, - ), - InkWell( - onTap: () { - setState(() { - isAllClinic = false; - if(widget.patientSearchViewModel.myInpatientClinicList.length > 0) - showBottomSheet = true; - }); - }, + if (!widget.isMyInPatient) + Container( + margin: EdgeInsets.only(left: 10.0, right: 10, top: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( child: Row( children: [ Radio( - value: 2, + value: 1, groupValue: isAllClinic ? 1 : 2, onChanged: (value) { setState(() { setState(() { - isAllClinic = false; - if(widget.patientSearchViewModel.myInpatientClinicList.length > 0) - showBottomSheet = true; + isAllClinic = true; + showBottomSheet = false; }); + widget.patientSearchViewModel + .setDefaultInPatientList(); }); }, activeColor: Colors.red, ), AppText( - selectedClinicName ?? "Select Clinic", + "All Clinic", fontSize: 15, ), - Container( - margin: EdgeInsets.only(bottom: 10), - child: Icon(FontAwesomeIcons.sortDown)) ], - )), - ], + ), + onTap: () { + setState(() { + isAllClinic = true; + showBottomSheet = false; + }); + widget.patientSearchViewModel.setDefaultInPatientList(); + }, + ), + InkWell( + onTap: () { + setState(() { + isAllClinic = false; + if (widget.patientSearchViewModel.InpatientClinicList + .length > + 0) showBottomSheet = true; + }); + }, + child: Row( + children: [ + Radio( + value: 2, + groupValue: isAllClinic ? 1 : 2, + onChanged: (value) { + setState(() { + setState(() { + isAllClinic = false; + if (widget.patientSearchViewModel + .InpatientClinicList.length > + 0) showBottomSheet = true; + }); + }); + }, + activeColor: Colors.red, + ), + AppText( + selectedClinicName ?? "Select Clinic", + fontSize: 15, + ), + Container( + margin: EdgeInsets.only(bottom: 10), + child: Icon(FontAwesomeIcons.sortDown)) + ], + )), + ], + ), ), - ), Container( - margin: EdgeInsets.only(left: 16, right: 16, bottom: 16, top: 5), + margin: EdgeInsets.only( + left: 16, + right: 16, + bottom: 16, + top: widget.isMyInPatient ? 15 : 5), child: Stack( children: [ AppTextFieldCustom( @@ -143,7 +145,7 @@ class _InPatientListPageState extends State { hasQuery = true; }); widget.patientSearchViewModel - .filterSearchResults(value, isAllClinic: isAllClinic); + .filterSearchResults(value, isAllClinic: isAllClinic, isMyInPatient:widget.isMyInPatient); }), Positioned( right: 35, @@ -160,7 +162,7 @@ class _InPatientListPageState extends State { onPressed: () { GifLoaderDialogUtils.showMyDialog(context); widget.patientSearchViewModel.sortInPatient( - isDes: isSortDes, isAllClinic: isAllClinic); + isDes: isSortDes, isAllClinic: isAllClinic, isMyInPatient:widget.isMyInPatient); isSortDes = !isSortDes; GifLoaderDialogUtils.hideDialog(context); }, @@ -170,146 +172,26 @@ class _InPatientListPageState extends State { ), ), widget.patientSearchViewModel.state == ViewState.Idle - ? widget.patientSearchViewModel.filteredInPatientItems.length > 0 - ? (widget.isMyInPatient && - widget.patientSearchViewModel.myIinPatientList - .length == - 0) - ? NoData() - : Expanded( - child: Container( - margin: EdgeInsets.symmetric(horizontal: 16.0), - child: NotificationListener( - child: ListView.builder( - itemCount: widget.patientSearchViewModel - .filteredInPatientItems.length, - scrollDirection: Axis.vertical, - // physics: ScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, index) { - if (!widget.isMyInPatient) - return PatientCard( - patientInfo: widget - .patientSearchViewModel - .filteredInPatientItems[index], - patientType: "1", - arrivalType: "1", - isInpatient: true, - isMyPatient: widget - .patientSearchViewModel - .filteredInPatientItems[index] - .doctorId == - widget.patientSearchViewModel - .doctorProfile.doctorID, - onTap: () { - FocusScopeNode currentFocus = - FocusScope.of(context); - if (!currentFocus.hasPrimaryFocus) { - currentFocus.unfocus(); - } - - Navigator.of(context).pushNamed( - PATIENTS_PROFILE, - arguments: { - "patient": widget - .patientSearchViewModel - .filteredInPatientItems[ - index], - "patientType": "1", - "from": "0", - "to": "0", - "isSearch": false, - "isInpatient": true, - "arrivalType": "1", - "isMyPatient": widget - .patientSearchViewModel - .filteredInPatientItems[ - index] - .doctorId == - widget - .patientSearchViewModel - .doctorProfile - .doctorID, - }); - }, - ); - else if (widget - .patientSearchViewModel - .filteredInPatientItems[index] - .doctorId == - widget.patientSearchViewModel - .doctorProfile.doctorID && - widget.isMyInPatient) - return PatientCard( - patientInfo: widget - .patientSearchViewModel - .filteredInPatientItems[index], - patientType: "1", - arrivalType: "1", - isInpatient: true, - isMyPatient: widget - .patientSearchViewModel - .filteredInPatientItems[index] - .doctorId == - widget.patientSearchViewModel - .doctorProfile.doctorID, - onTap: () { - FocusScopeNode currentFocus = - FocusScope.of(context); - if (!currentFocus.hasPrimaryFocus) { - currentFocus.unfocus(); - } - - Navigator.of(context).pushNamed( - PATIENTS_PROFILE, - arguments: { - "patient": widget - .patientSearchViewModel - .filteredInPatientItems[ - index], - "patientType": "1", - "from": "0", - "to": "0", - "isSearch": false, - "isInpatient": true, - "arrivalType": "1", - "isMyPatient": widget - .patientSearchViewModel - .filteredInPatientItems[ - index] - .doctorId == - widget - .patientSearchViewModel - .doctorProfile - .doctorID, - }); - }, - ); - else - return SizedBox(); - }), - onNotification: (t) { - if (isAllClinic && !hasQuery) if (t - is ScrollUpdateNotification) { - if (t.metrics.pixels >= - t.metrics.maxScrollExtent - 50) { - widget.patientSearchViewModel - .addOnFilteredList(); - } - - if (t.metrics.pixels <= - t.metrics.minScrollExtent - 50) { - widget.patientSearchViewModel - .removeOnFilteredList(); - } - - } - return; - }, - ), - ), - ) - : NoData() + ? (widget.isMyInPatient && + widget.patientSearchViewModel.myIinPatientList.length > 0) + ? ListOfMyInpatient( + isAllClinic: isAllClinic, + hasQuery: hasQuery, + patientSearchViewModel: widget.patientSearchViewModel) + : widget.patientSearchViewModel.filteredInPatientItems + .length > + 0 + ? (widget.isMyInPatient && + widget.patientSearchViewModel.myIinPatientList + .length == + 0) + ? NoData() + : ListOfAllInPatient( + isAllClinic: isAllClinic, + hasQuery: hasQuery, + patientSearchViewModel: + widget.patientSearchViewModel) + : NoData() : Center( child: Container( height: 300, @@ -326,8 +208,8 @@ class _InPatientListPageState extends State { height: MediaQuery.of(context).size.height * 0.5, color: Colors.white, child: ListView.builder( - itemCount: widget - .patientSearchViewModel.myInpatientClinicList.length, + itemCount: + widget.patientSearchViewModel.InpatientClinicList.length, scrollDirection: Axis.vertical, physics: ScrollPhysics(), shrinkWrap: true, @@ -338,17 +220,17 @@ class _InPatientListPageState extends State { isAllClinic = false; showBottomSheet = false; selectedClinicName = widget.patientSearchViewModel - .myInpatientClinicList[index]; + .InpatientClinicList[index]; }); widget.patientSearchViewModel.filterByClinic( clinicName: widget.patientSearchViewModel - .myInpatientClinicList[index]); + .InpatientClinicList[index]); }, child: Row( children: [ Radio( value: widget.patientSearchViewModel - .myInpatientClinicList[index], + .InpatientClinicList[index], groupValue: selectedClinicName, onChanged: (value) { setState(() { @@ -363,7 +245,7 @@ class _InPatientListPageState extends State { activeColor: Colors.red, ), AppText(widget.patientSearchViewModel - .myInpatientClinicList[index]), + .InpatientClinicList[index]), ], )); }), @@ -373,3 +255,4 @@ class _InPatientListPageState extends State { } + diff --git a/lib/screens/patients/In_patient/list_of_all_in_patient.dart b/lib/screens/patients/In_patient/list_of_all_in_patient.dart new file mode 100644 index 00000000..4908a848 --- /dev/null +++ b/lib/screens/patients/In_patient/list_of_all_in_patient.dart @@ -0,0 +1,124 @@ +import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart'; +import 'package:doctor_app_flutter/widgets/patients/patient_card/PatientCard.dart'; +import 'package:flutter/material.dart'; + +import '../../../routes.dart'; +import 'NoData.dart'; + +class ListOfAllInPatient extends StatelessWidget { + const ListOfAllInPatient({ + Key key, + @required this.isAllClinic, + @required this.hasQuery, + this.patientSearchViewModel, + }) : super(key: key); + + final bool isAllClinic; + final bool hasQuery; + + final PatientSearchViewModel patientSearchViewModel; + + @override + Widget build(BuildContext context) { + return Expanded( + child: Container( + margin: EdgeInsets.symmetric(horizontal: 16.0), + child: patientSearchViewModel.filteredInPatientItems.length == 0 + ? NoData() + :NotificationListener( + child: ListView.builder( + itemCount: + patientSearchViewModel.filteredInPatientItems.length, + scrollDirection: Axis.vertical, + // physics: ScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index) { + // if (!isMyInPatient) + return PatientCard( + patientInfo: patientSearchViewModel + .filteredInPatientItems[index], + patientType: "1", + arrivalType: "1", + isInpatient: true, + isMyPatient: patientSearchViewModel + .filteredInPatientItems[index].doctorId == + patientSearchViewModel.doctorProfile.doctorID, + onTap: () { + FocusScopeNode currentFocus = FocusScope.of(context); + if (!currentFocus.hasPrimaryFocus) { + currentFocus.unfocus(); + } + + Navigator.of(context) + .pushNamed(PATIENTS_PROFILE, arguments: { + "patient": patientSearchViewModel + .filteredInPatientItems[index], + "patientType": "1", + "from": "0", + "to": "0", + "isSearch": false, + "isInpatient": true, + "arrivalType": "1", + "isMyPatient": patientSearchViewModel + .filteredInPatientItems[index].doctorId == + patientSearchViewModel.doctorProfile.doctorID, + }); + }, + ); + // else if (widget.patientSearchViewModel + // .filteredInPatientItems[index].doctorId == + // widget.patientSearchViewModel.doctorProfile.doctorID && + // widget.isMyInPatient) + // return PatientCard( + // patientInfo: widget + // .patientSearchViewModel.filteredInPatientItems[index], + // patientType: "1", + // arrivalType: "1", + // isInpatient: true, + // isMyPatient: widget.patientSearchViewModel + // .filteredInPatientItems[index].doctorId == + // widget.patientSearchViewModel.doctorProfile.doctorID, + // onTap: () { + // FocusScopeNode currentFocus = FocusScope.of(context); + // if (!currentFocus.hasPrimaryFocus) { + // currentFocus.unfocus(); + // } + // + // Navigator.of(context) + // .pushNamed(PATIENTS_PROFILE, arguments: { + // "patient": widget.patientSearchViewModel + // .filteredInPatientItems[index], + // "patientType": "1", + // "from": "0", + // "to": "0", + // "isSearch": false, + // "isInpatient": true, + // "arrivalType": "1", + // "isMyPatient": widget.patientSearchViewModel + // .filteredInPatientItems[index].doctorId == + // widget + // .patientSearchViewModel.doctorProfile.doctorID, + // }); + // }, + // ); + // else + // return SizedBox(); + }), + onNotification: (t) { + if (isAllClinic && !hasQuery) if (t + is ScrollUpdateNotification) { + if (t.metrics.pixels >= t.metrics.maxScrollExtent - 50) { + patientSearchViewModel.addOnFilteredList(); + } + + if (t.metrics.pixels <= t.metrics.minScrollExtent - 50) { + patientSearchViewModel.removeOnFilteredList(); + } + } + return; + }, + ), + ), + ); + } +} diff --git a/lib/screens/patients/In_patient/list_of_my_inpatient.dart b/lib/screens/patients/In_patient/list_of_my_inpatient.dart new file mode 100644 index 00000000..306f99ac --- /dev/null +++ b/lib/screens/patients/In_patient/list_of_my_inpatient.dart @@ -0,0 +1,76 @@ +import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart'; +import 'package:doctor_app_flutter/widgets/patients/patient_card/PatientCard.dart'; +import 'package:flutter/material.dart'; + +import '../../../routes.dart'; +import 'NoData.dart'; +class ListOfMyInpatient extends StatelessWidget { + const ListOfMyInpatient({ + Key key, + @required this.isAllClinic, + @required this.hasQuery, + this.patientSearchViewModel, + }) : super(key: key); + + final bool isAllClinic; + final bool hasQuery; + final PatientSearchViewModel patientSearchViewModel; + + @override + Widget build(BuildContext context) { + return Expanded( + child:Container( + margin: EdgeInsets.symmetric(horizontal: 16.0), + child: patientSearchViewModel.filteredMyInPatientItems.length == 0 + ? NoData():NotificationListener( + child: ListView.builder( + itemCount: patientSearchViewModel.filteredMyInPatientItems.length, + scrollDirection: Axis.vertical, + // physics: ScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index) { + return PatientCard( + patientInfo: patientSearchViewModel.filteredMyInPatientItems[index], + patientType: "1", + arrivalType: "1", + isInpatient: true, + isMyPatient: true, + onTap: () { + FocusScopeNode currentFocus = FocusScope.of(context); + if (!currentFocus.hasPrimaryFocus) { + currentFocus.unfocus(); + } + + Navigator.of(context) + .pushNamed(PATIENTS_PROFILE, arguments: { + "patient": + patientSearchViewModel.filteredInPatientItems[index], + "patientType": "1", + "from": "0", + "to": "0", + "isSearch": false, + "isInpatient": true, + "arrivalType": "1", + "isMyPatient": true, + }); + }, + ); + }), + onNotification: (t) { + if (isAllClinic && !hasQuery) if (t is ScrollUpdateNotification) { + //TODO Elham* + // if (t.metrics.pixels >= t.metrics.maxScrollExtent - 50) { + // patientSearchViewModel.addOnFilteredList(); + // } + // + // if (t.metrics.pixels <= t.metrics.minScrollExtent - 50) { + // patientSearchViewModel.removeOnFilteredList(); + // } + } + return; + }, + ), + ), + ); + } +} From de5621a629f115f7f4bc4c906e54ff9d6c027dad Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 9 Sep 2021 15:18:07 +0300 Subject: [PATCH 5/6] fix issue after merge the dev --- .../In_patient/in_patient_list_page.dart | 13 +++++----- .../In_patient/list_of_all_in_patient.dart | 24 +++++++++++-------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/screens/patients/In_patient/in_patient_list_page.dart b/lib/screens/patients/In_patient/in_patient_list_page.dart index 876c31ba..251054e1 100644 --- a/lib/screens/patients/In_patient/in_patient_list_page.dart +++ b/lib/screens/patients/In_patient/in_patient_list_page.dart @@ -152,8 +152,9 @@ class _InPatientListPageState extends State { setState(() { hasQuery = true; }); - widget.patientSearchViewModel - .filterSearchResults(value, isAllClinic: isAllClinic, isMyInPatient:widget.isMyInPatient); + widget.patientSearchViewModel.filterSearchResults(value, + isAllClinic: isAllClinic, + isMyInPatient: widget.isMyInPatient); }), Positioned( right: 35, @@ -170,7 +171,9 @@ class _InPatientListPageState extends State { onPressed: () { GifLoaderDialogUtils.showMyDialog(context); widget.patientSearchViewModel.sortInPatient( - isDes: isSortDes, isAllClinic: isAllClinic, isMyInPatient:widget.isMyInPatient); + isDes: isSortDes, + isAllClinic: isAllClinic, + isMyInPatient: widget.isMyInPatient); isSortDes = !isSortDes; GifLoaderDialogUtils.hideDialog(context); }, @@ -197,6 +200,7 @@ class _InPatientListPageState extends State { : ListOfAllInPatient( isAllClinic: isAllClinic, hasQuery: hasQuery, + scrollController: _scrollController, patientSearchViewModel: widget.patientSearchViewModel) : NoData() @@ -261,6 +265,3 @@ class _InPatientListPageState extends State { ); } } - - - diff --git a/lib/screens/patients/In_patient/list_of_all_in_patient.dart b/lib/screens/patients/In_patient/list_of_all_in_patient.dart index 4908a848..9c648e66 100644 --- a/lib/screens/patients/In_patient/list_of_all_in_patient.dart +++ b/lib/screens/patients/In_patient/list_of_all_in_patient.dart @@ -11,22 +11,26 @@ class ListOfAllInPatient extends StatelessWidget { @required this.isAllClinic, @required this.hasQuery, this.patientSearchViewModel, + this.scrollController, }) : super(key: key); final bool isAllClinic; final bool hasQuery; + final ScrollController scrollController; + final PatientSearchViewModel patientSearchViewModel; @override Widget build(BuildContext context) { return Expanded( - child: Container( - margin: EdgeInsets.symmetric(horizontal: 16.0), - child: patientSearchViewModel.filteredInPatientItems.length == 0 - ? NoData() - :NotificationListener( + child: Container( + margin: EdgeInsets.symmetric(horizontal: 16.0), + child: patientSearchViewModel.filteredInPatientItems.length == 0 + ? NoData() + : NotificationListener( child: ListView.builder( + controller: scrollController, itemCount: patientSearchViewModel.filteredInPatientItems.length, scrollDirection: Axis.vertical, @@ -104,21 +108,21 @@ class ListOfAllInPatient extends StatelessWidget { // else // return SizedBox(); }), - onNotification: (t) { - if (isAllClinic && !hasQuery) if (t + onNotification: (notification) { + if (isAllClinic && !hasQuery) if (notification is ScrollUpdateNotification) { - if (t.metrics.pixels >= t.metrics.maxScrollExtent - 50) { + if (notification.metrics.pixels >= notification.metrics.maxScrollExtent - 50) { patientSearchViewModel.addOnFilteredList(); } - if (t.metrics.pixels <= t.metrics.minScrollExtent - 50) { + if (notification.metrics.pixels <= notification.metrics.minScrollExtent - 50) { patientSearchViewModel.removeOnFilteredList(); } } return; }, ), - ), + ), ); } } From f2dbfaf2be3cf0e77e26845e2ff82079c1c52f8f Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 9 Sep 2021 15:30:46 +0300 Subject: [PATCH 6/6] fix issue after merge the dev --- lib/screens/patients/In_patient/in_patient_list_page.dart | 8 -------- .../patients/In_patient/list_of_all_in_patient.dart | 7 +------ 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/screens/patients/In_patient/in_patient_list_page.dart b/lib/screens/patients/In_patient/in_patient_list_page.dart index 251054e1..61abf434 100644 --- a/lib/screens/patients/In_patient/in_patient_list_page.dart +++ b/lib/screens/patients/In_patient/in_patient_list_page.dart @@ -30,20 +30,13 @@ class _InPatientListPageState extends State { bool hasQuery = false; bool showBottomSheet = false; String selectedClinicName; - ScrollController _scrollController; @override void dispose() { _searchController.dispose(); - _scrollController.dispose(); super.dispose(); } - @override - void initState() { - _scrollController = new ScrollController(); - super.initState(); - } @override Widget build(BuildContext context) { @@ -200,7 +193,6 @@ class _InPatientListPageState extends State { : ListOfAllInPatient( isAllClinic: isAllClinic, hasQuery: hasQuery, - scrollController: _scrollController, patientSearchViewModel: widget.patientSearchViewModel) : NoData() diff --git a/lib/screens/patients/In_patient/list_of_all_in_patient.dart b/lib/screens/patients/In_patient/list_of_all_in_patient.dart index 9c648e66..6aa13094 100644 --- a/lib/screens/patients/In_patient/list_of_all_in_patient.dart +++ b/lib/screens/patients/In_patient/list_of_all_in_patient.dart @@ -11,13 +11,11 @@ class ListOfAllInPatient extends StatelessWidget { @required this.isAllClinic, @required this.hasQuery, this.patientSearchViewModel, - this.scrollController, }) : super(key: key); final bool isAllClinic; final bool hasQuery; - final ScrollController scrollController; final PatientSearchViewModel patientSearchViewModel; @@ -28,16 +26,13 @@ class ListOfAllInPatient extends StatelessWidget { margin: EdgeInsets.symmetric(horizontal: 16.0), child: patientSearchViewModel.filteredInPatientItems.length == 0 ? NoData() - : NotificationListener( + : NotificationListener( child: ListView.builder( - controller: scrollController, itemCount: patientSearchViewModel.filteredInPatientItems.length, scrollDirection: Axis.vertical, - // physics: ScrollPhysics(), shrinkWrap: true, itemBuilder: (context, index) { - // if (!isMyInPatient) return PatientCard( patientInfo: patientSearchViewModel .filteredInPatientItems[index],