From 83f04bc0e6d5f2402cef9edcae1572407bcae4d7 Mon Sep 17 00:00:00 2001 From: aamir-csol Date: Mon, 12 Jan 2026 10:19:50 +0300 Subject: [PATCH] search filter on select doctor page. --- .../book_appointments_view_model.dart | 3 + .../book_appointment/select_doctor_page.dart | 86 +++++++++++-------- 2 files changed, 53 insertions(+), 36 deletions(-) diff --git a/lib/features/book_appointments/book_appointments_view_model.dart b/lib/features/book_appointments/book_appointments_view_model.dart index cbed940..380d2db 100644 --- a/lib/features/book_appointments/book_appointments_view_model.dart +++ b/lib/features/book_appointments/book_appointments_view_model.dart @@ -49,6 +49,7 @@ class BookAppointmentsViewModel extends ChangeNotifier { bool isLiveCareSchedule = false; bool isGetDocForHealthCal = false; + bool showSortFilterButtons = false; int? calculationID = 0; bool isSortByClinic = true; @@ -200,8 +201,10 @@ class BookAppointmentsViewModel extends ChangeNotifier { void filterClinics(String? query) { if (query!.isEmpty) { _filteredClinicsList = List.from(clinicsList); + showSortFilterButtons = false; } else { _filteredClinicsList = clinicsList.where((clinic) => clinic.clinicDescription?.toLowerCase().contains(query!.toLowerCase()) ?? false).toList(); + showSortFilterButtons = query.length >= 3; } notifyListeners(); } diff --git a/lib/presentation/book_appointment/select_doctor_page.dart b/lib/presentation/book_appointment/select_doctor_page.dart index d77e152..569e8ac 100644 --- a/lib/presentation/book_appointment/select_doctor_page.dart +++ b/lib/presentation/book_appointment/select_doctor_page.dart @@ -40,9 +40,7 @@ class _SelectDoctorPageState extends State { late AppState appState; late BookAppointmentsViewModel bookAppointmentsViewModel; - // Scroll controller to control page scrolling when a group expands late ScrollController _scrollController; - // Map of keys for each item to allow scrolling to them final Map _itemKeys = {}; @override @@ -79,6 +77,20 @@ class _SelectDoctorPageState extends State { backgroundColor: AppColors.bgScaffoldColor, body: CollapsingListView( title: "Choose Doctor".needTranslation, + // bottomChild: Container( + // decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, customBorder: BorderRadius.only(topLeft: Radius.circular(24.r), topRight: Radius.circular(24.r))), + // padding: EdgeInsets.symmetric(vertical: 20.h, horizontal: 20.h), + // child: CustomButton( + // text: LocaleKeys.search.tr(), + // onPressed: () { + // }, + // icon: null, + // fontSize: 16.f, + // backgroundColor: AppColors.primaryRedColor, + // borderColor: AppColors.primaryRedColor, + // borderRadius: 12.r, + // fontWeight: FontWeight.w500), + // ), child: SingleChildScrollView( controller: _scrollController, child: Padding( @@ -124,40 +136,42 @@ class _SelectDoctorPageState extends State { ], ), SizedBox(height: 16.h), - Row( - children: [ - CustomButton( - text: LocaleKeys.byClinic.tr(context: context), - onPressed: () { - bookAppointmentsVM.setIsSortByClinic(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.setIsSortByClinic(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), - SizedBox(height: 16.h), + if (bookAppointmentsViewModel.isGetDocForHealthCal && bookAppointmentsVM.showSortFilterButtons) + Row( + children: [ + CustomButton( + text: LocaleKeys.byClinic.tr(context: context), + onPressed: () { + bookAppointmentsVM.setIsSortByClinic(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.setIsSortByClinic(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), + if (bookAppointmentsViewModel.isGetDocForHealthCal && bookAppointmentsVM.showSortFilterButtons) + SizedBox(height: 16.h), Row( mainAxisSize: MainAxisSize.max, children: [