search doctor by name filter.

pull/149/head
aamir-csol 3 days ago
parent 83f04bc0e6
commit c11e859df1

@ -165,6 +165,27 @@ class BookAppointmentsViewModel extends ChangeNotifier {
notifyListeners();
}
// Sort filtered doctor list by clinic or hospital
void sortFilteredDoctorList(bool sortByClinic) {
isSortByClinic = sortByClinic;
if (sortByClinic) {
// Sort by clinic name
filteredDoctorList.sort((a, b) {
final clinicA = (a.clinicName ?? 'Unknown').toLowerCase();
final clinicB = (b.clinicName ?? 'Unknown').toLowerCase();
return clinicA.compareTo(clinicB);
});
} else {
// Sort by hospital/project name
filteredDoctorList.sort((a, b) {
final hospitalA = (a.projectName ?? 'Unknown').toLowerCase();
final hospitalB = (b.projectName ?? 'Unknown').toLowerCase();
return hospitalA.compareTo(hospitalB);
});
}
notifyListeners();
}
// Group doctors by clinic and hospital
void _groupDoctorsList() {
final clinicMap = <String, List<DoctorsListResponseModel>>{};

@ -89,25 +89,23 @@ class _SearchDoctorByNameState extends State<SearchDoctorByName> {
child: SizedBox(
height: 56.h,
width: 56.h,
child: DecoratedBox(decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
child: DecoratedBox(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor,
borderRadius: 10.h,
hasShadow: false,
),
child: Utils.buildSvgWithAssets(icon: AppAssets.ic_filters,
child: Utils.buildSvgWithAssets(
icon: AppAssets.ic_filters,
height: 24.h,
width: 24.h, ).paddingAll(16.h).onPress((){
width: 24.h,
).paddingAll(16.h).onPress(() {
context.read<DoctorFilterViewModel>()
..clearSelection()
..clearSearchFilters()
..getFiltersFromDoctorList(
bookAppointmentsViewModel.doctorsList
)..setSelections(
bookAppointmentsViewModel.selectedFacilityForFilters?.toList(),
bookAppointmentsViewModel.selectedRegionForFilters?.toList(),
bookAppointmentsViewModel.selectedClinicForFilters,
bookAppointmentsViewModel.selectedHospitalForFilters,
bookAppointmentsViewModel.applyFilters) ;
..getFiltersFromDoctorList(bookAppointmentsViewModel.doctorsList)
..setSelections(bookAppointmentsViewModel.selectedFacilityForFilters?.toList(), bookAppointmentsViewModel.selectedRegionForFilters?.toList(),
bookAppointmentsViewModel.selectedClinicForFilters, bookAppointmentsViewModel.selectedHospitalForFilters, bookAppointmentsViewModel.applyFilters);
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) => DoctorsFilters(), // Replace YourNewPage with your actual page widget
@ -136,9 +134,43 @@ class _SearchDoctorByNameState extends State<SearchDoctorByName> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (bookAppointmentsVM.isDoctorSearchByNameStarted)
Row(
children: [
CustomButton(
text: LocaleKeys.byClinic.tr(context: context),
onPressed: () {
bookAppointmentsVM.sortFilteredDoctorList(true);
},
backgroundColor: bookAppointmentsVM.isSortByClinic ? AppColors.bgRedLightColor : AppColors.whiteColor,
borderColor: bookAppointmentsVM.isSortByClinic ? AppColors.primaryRedColor : AppColors.textColor.withOpacity(0.2),
textColor: bookAppointmentsVM.isSortByClinic ? AppColors.primaryRedColor : AppColors.blackColor,
fontSize: 12,
fontWeight: FontWeight.w500,
borderRadius: 10,
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
height: 40.h,
),
SizedBox(width: 8.h),
CustomButton(
text: LocaleKeys.byHospital.tr(context: context),
onPressed: () {
bookAppointmentsVM.sortFilteredDoctorList(false);
},
backgroundColor: bookAppointmentsVM.isSortByClinic ? AppColors.whiteColor : AppColors.bgRedLightColor,
borderColor: bookAppointmentsVM.isSortByClinic ? AppColors.textColor.withOpacity(0.2) : AppColors.primaryRedColor,
textColor: bookAppointmentsVM.isSortByClinic ? AppColors.blackColor : AppColors.primaryRedColor,
fontSize: 12,
fontWeight: FontWeight.w500,
borderRadius: 10,
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
height: 40.h,
),
],
).paddingSymmetrical(0.h, 0.h),
bookAppointmentsVM.isDoctorSearchByNameStarted
? ListView.separated(
padding: EdgeInsets.only(top: 24.h),
padding: EdgeInsets.only(top: 20.h),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: bookAppointmentsVM.isDoctorsListLoading ? 5 : bookAppointmentsVM.filteredDoctorList.length,
@ -261,6 +293,7 @@ class _SearchDoctorByNameState extends State<SearchDoctorByName> {
),
);
}
@override
void dispose() {
bookAppointmentsViewModel.doctorsList.clear();

Loading…
Cancel
Save