From a4b24dad124419925a7d4b99a8bc24645eca2c78 Mon Sep 17 00:00:00 2001 From: "taha.alam@cloudsolutions.com.sa" Date: Wed, 10 Dec 2025 10:41:35 +0300 Subject: [PATCH] clear filter issue fix --- lib/config/localized_values.dart | 4 + .../viewModel/PatientSearchViewModel.dart | 2 +- .../patients/In_patient/filter_date_page.dart | 119 +++++++++++++----- .../bottom_sheet_title.dart | 6 +- .../translations_delegate_base_utils.dart | 1 + 5 files changed, 102 insertions(+), 30 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 3c4db1f7..3a6c2d27 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1266,5 +1266,9 @@ const Map> localizedValues = { "kindlySelectCondition": { "en": "Kindly select condition", "ar": "يرجى تحديد الشرط" + }, + "reset": { + "en": "Reset", + "ar": "إعادة تعيين" } }; diff --git a/lib/core/viewModel/PatientSearchViewModel.dart b/lib/core/viewModel/PatientSearchViewModel.dart index e30d31c5..15156250 100644 --- a/lib/core/viewModel/PatientSearchViewModel.dart +++ b/lib/core/viewModel/PatientSearchViewModel.dart @@ -191,7 +191,7 @@ class PatientSearchViewModel extends BaseViewModel { } FutureOr paginatedInPatientCall(String? selectedClinicName, String? query, bool? isSortDes,{bool isMyInPatient = false,bool isAllClinic = false }) async { - if(isVidaPlusProject = false) return; + if(isVidaPlusProject == false) return; if(this.requestModel == null) return; PatientSearchRequestModel requestModel = this.requestModel!; diff --git a/lib/screens/patients/In_patient/filter_date_page.dart b/lib/screens/patients/In_patient/filter_date_page.dart index b4147f25..7a41af63 100644 --- a/lib/screens/patients/In_patient/filter_date_page.dart +++ b/lib/screens/patients/In_patient/filter_date_page.dart @@ -25,9 +25,15 @@ class FilterDatePage extends StatefulWidget { } class _FilterDatePageState extends State { + bool showResetButton = false; + @override void initState() { - // TODO: implement initState + + setState(() { + showResetButton = widget.patientSearchViewModel + .selectedFromDate != null; + }); super.initState(); } @@ -47,6 +53,14 @@ class _FilterDatePageState extends State { children: [ BottomSheetTitle( title: TranslationBase.of(context).filterInPatient, + onCrossClicked: (){ + if(showResetButton == false){ + widget.patientSearchViewModel + .selectedFromDate = null; + widget.patientSearchViewModel + .selectedToDate = null; + } + }, ), SizedBox( height: 10.0, @@ -130,35 +144,84 @@ class _FilterDatePageState extends State { SizedBox( height: 10, ), - Container( - child: FractionallySizedBox( - widthFactor: .80, - child: Center( - child: AppButton( - title: TranslationBase.of(context).search, - padding: 10, - color: AppGlobal.appGreenColor, - onPressed: () async { - if (widget.patientSearchViewModel.selectedFromDate == - null || - widget.patientSearchViewModel.selectedToDate == - null) { - Utils.showErrorToast( - "Please Select All The date Fields "); - } else { - Navigator.pop(context); - await widget.patientSearchViewModel.getInPatientList( - PatientSearchRequestModel( - from: - "${AppDateUtils.convertDateToFormat(widget.patientSearchViewModel.selectedFromDate!, "yyyy-MM-dd")} 00:00:00", - to: "${AppDateUtils.convertDateToFormat(widget.patientSearchViewModel.selectedToDate!, "yyyy-MM-dd")} 00:00:00", - searchType: null)..transformDataForVidaPlus(), - isForceFullRefresh: true); - } - }, + Row( + children: [ + Expanded( + child: Container( + child: FractionallySizedBox( + widthFactor: .80, + child: Center( + child: AppButton( + title: TranslationBase.of(context).search, + padding: 10, + color: AppGlobal.appGreenColor, + onPressed: () async { + if (widget.patientSearchViewModel.selectedFromDate == + null || + widget.patientSearchViewModel.selectedToDate == + null) { + Utils.showErrorToast( + "Please Select All The date Fields "); + } else { + Navigator.pop(context); + await widget.patientSearchViewModel.getInPatientList( + PatientSearchRequestModel( + from: + "${AppDateUtils.convertDateToFormat(widget.patientSearchViewModel.selectedFromDate!, "yyyy-MM-dd")} 00:00:00", + to: "${AppDateUtils.convertDateToFormat(widget.patientSearchViewModel.selectedToDate!, "yyyy-MM-dd")} 00:00:00", + searchType: null)..transformDataForVidaPlus(), + isForceFullRefresh: true, isVidaPlusProject: true); + } + }, + ), + ), + ), ), ), - ), + Visibility( + visible: showResetButton, + child: Expanded( + child: Container( + child: FractionallySizedBox( + widthFactor: .80, + child: Center( + child: AppButton( + title: TranslationBase.of(context).reset, + padding: 10, + color: AppGlobal.appRedColor, + onPressed: () async { + this.widget.patientSearchViewModel.selectedToDate = null; + this.widget.patientSearchViewModel.selectedFromDate = null; + + PatientSearchRequestModel requestModel = PatientSearchRequestModel(); + DateTime dateTime = DateTime.now(); + String currentDate = AppDateUtils.convertDateToFormat( + dateTime, + 'yyyy-MM-dd'); + print("the current date is $currentDate"); + requestModel.from = "$currentDate 00:00:00"; + + dateTime = dateTime.add(Duration(days: 1)); + currentDate = AppDateUtils.convertDateToFormat( + dateTime, + 'yyyy-MM-dd'); + requestModel.to = "$currentDate 00:00:00"; + requestModel.pageSize = 10; + requestModel.pageIndex = 0; + requestModel.searchType = null; + requestModel.transformDataForVidaPlus(); + Navigator.pop(context); + await widget.patientSearchViewModel.getInPatientList( + requestModel, + isForceFullRefresh: true,isVidaPlusProject: true); + }, + ), + ), + ), + ), + ), + ) + ], ), SizedBox( height: 5, 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 93f3e824..132f10d7 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,3 +1,4 @@ + import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:flutter/material.dart'; @@ -6,10 +7,12 @@ class BottomSheetTitle extends StatelessWidget implements PreferredSizeWidget { BottomSheetTitle({ Key? key, this.title = '', - this.isClose =true + this.isClose =true, + this.onCrossClicked }) : super(key: key); bool isClose; final String title; + final VoidCallback? onCrossClicked; double headerHeight = SizeConfig.heightMultiplier! * 15; @override @@ -41,6 +44,7 @@ class BottomSheetTitle extends StatelessWidget implements PreferredSizeWidget { InkWell( onTap: () { Navigator.pop(context); + onCrossClicked?.call(); }, child: isClose ? Icon(DoctorApp.close_1, size: SizeConfig.getTextMultiplierBasedOnWidth() * 5, color: Color(0xFF2B353E)) :SizedBox()) ], diff --git a/lib/utils/translations_delegate_base_utils.dart b/lib/utils/translations_delegate_base_utils.dart index ebf63853..ff138e27 100644 --- a/lib/utils/translations_delegate_base_utils.dart +++ b/lib/utils/translations_delegate_base_utils.dart @@ -2000,6 +2000,7 @@ class TranslationBase { String get remarksNotAdded => localizedValues['remarksNotAdded']![locale.languageCode]!; String get addDoctorRemarks => localizedValues['addDoctorRemarks']![locale.languageCode]!; String get kindlySelectCondition => localizedValues['kindlySelectCondition']![locale.languageCode]!; + String get reset => localizedValues['reset']![locale.languageCode]!; } class TranslationBaseDelegate extends LocalizationsDelegate {