From a1f972909134bc57b86408fc7728005380e3c1ef Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 9 Sep 2021 11:48:44 +0300 Subject: [PATCH] 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 { )); } } - -