search filter on select doctor page.

pull/147/head
aamir-csol 3 days ago
parent 38d8341963
commit 83f04bc0e6

@ -49,6 +49,7 @@ class BookAppointmentsViewModel extends ChangeNotifier {
bool isLiveCareSchedule = false; bool isLiveCareSchedule = false;
bool isGetDocForHealthCal = false; bool isGetDocForHealthCal = false;
bool showSortFilterButtons = false;
int? calculationID = 0; int? calculationID = 0;
bool isSortByClinic = true; bool isSortByClinic = true;
@ -200,8 +201,10 @@ class BookAppointmentsViewModel extends ChangeNotifier {
void filterClinics(String? query) { void filterClinics(String? query) {
if (query!.isEmpty) { if (query!.isEmpty) {
_filteredClinicsList = List.from(clinicsList); _filteredClinicsList = List.from(clinicsList);
showSortFilterButtons = false;
} else { } else {
_filteredClinicsList = clinicsList.where((clinic) => clinic.clinicDescription?.toLowerCase().contains(query!.toLowerCase()) ?? false).toList(); _filteredClinicsList = clinicsList.where((clinic) => clinic.clinicDescription?.toLowerCase().contains(query!.toLowerCase()) ?? false).toList();
showSortFilterButtons = query.length >= 3;
} }
notifyListeners(); notifyListeners();
} }

@ -40,9 +40,7 @@ class _SelectDoctorPageState extends State<SelectDoctorPage> {
late AppState appState; late AppState appState;
late BookAppointmentsViewModel bookAppointmentsViewModel; late BookAppointmentsViewModel bookAppointmentsViewModel;
// Scroll controller to control page scrolling when a group expands
late ScrollController _scrollController; late ScrollController _scrollController;
// Map of keys for each item to allow scrolling to them
final Map<int, GlobalKey> _itemKeys = {}; final Map<int, GlobalKey> _itemKeys = {};
@override @override
@ -79,6 +77,20 @@ class _SelectDoctorPageState extends State<SelectDoctorPage> {
backgroundColor: AppColors.bgScaffoldColor, backgroundColor: AppColors.bgScaffoldColor,
body: CollapsingListView( body: CollapsingListView(
title: "Choose Doctor".needTranslation, 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( child: SingleChildScrollView(
controller: _scrollController, controller: _scrollController,
child: Padding( child: Padding(
@ -124,40 +136,42 @@ class _SelectDoctorPageState extends State<SelectDoctorPage> {
], ],
), ),
SizedBox(height: 16.h), SizedBox(height: 16.h),
Row( if (bookAppointmentsViewModel.isGetDocForHealthCal && bookAppointmentsVM.showSortFilterButtons)
children: [ Row(
CustomButton( children: [
text: LocaleKeys.byClinic.tr(context: context), CustomButton(
onPressed: () { text: LocaleKeys.byClinic.tr(context: context),
bookAppointmentsVM.setIsSortByClinic(true); onPressed: () {
}, bookAppointmentsVM.setIsSortByClinic(true);
backgroundColor: bookAppointmentsVM.isSortByClinic ? AppColors.bgRedLightColor : AppColors.whiteColor, },
borderColor: bookAppointmentsVM.isSortByClinic ? AppColors.primaryRedColor : AppColors.textColor.withOpacity(0.2), backgroundColor: bookAppointmentsVM.isSortByClinic ? AppColors.bgRedLightColor : AppColors.whiteColor,
textColor: bookAppointmentsVM.isSortByClinic ? AppColors.primaryRedColor : AppColors.blackColor, borderColor: bookAppointmentsVM.isSortByClinic ? AppColors.primaryRedColor : AppColors.textColor.withOpacity(0.2),
fontSize: 12, textColor: bookAppointmentsVM.isSortByClinic ? AppColors.primaryRedColor : AppColors.blackColor,
fontWeight: FontWeight.w500, fontSize: 12,
borderRadius: 10, fontWeight: FontWeight.w500,
padding: EdgeInsets.fromLTRB(10, 0, 10, 0), borderRadius: 10,
height: 40.h, padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
), height: 40.h,
SizedBox(width: 8.h), ),
CustomButton( SizedBox(width: 8.h),
text: LocaleKeys.byHospital.tr(context: context), CustomButton(
onPressed: () { text: LocaleKeys.byHospital.tr(context: context),
bookAppointmentsVM.setIsSortByClinic(false); onPressed: () {
}, bookAppointmentsVM.setIsSortByClinic(false);
backgroundColor: bookAppointmentsVM.isSortByClinic ? AppColors.whiteColor : AppColors.bgRedLightColor, },
borderColor: bookAppointmentsVM.isSortByClinic ? AppColors.textColor.withOpacity(0.2) : AppColors.primaryRedColor, backgroundColor: bookAppointmentsVM.isSortByClinic ? AppColors.whiteColor : AppColors.bgRedLightColor,
textColor: bookAppointmentsVM.isSortByClinic ? AppColors.blackColor : AppColors.primaryRedColor, borderColor: bookAppointmentsVM.isSortByClinic ? AppColors.textColor.withOpacity(0.2) : AppColors.primaryRedColor,
fontSize: 12, textColor: bookAppointmentsVM.isSortByClinic ? AppColors.blackColor : AppColors.primaryRedColor,
fontWeight: FontWeight.w500, fontSize: 12,
borderRadius: 10, fontWeight: FontWeight.w500,
padding: EdgeInsets.fromLTRB(10, 0, 10, 0), borderRadius: 10,
height: 40.h, padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
), height: 40.h,
], ),
).paddingSymmetrical(0.h, 0.h), ],
SizedBox(height: 16.h), ).paddingSymmetrical(0.h, 0.h),
if (bookAppointmentsViewModel.isGetDocForHealthCal && bookAppointmentsVM.showSortFilterButtons)
SizedBox(height: 16.h),
Row( Row(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: [ children: [

Loading…
Cancel
Save