dev_aamir #149

Merged
Haroon6138 merged 2 commits from dev_aamir into master 3 days ago

@ -165,6 +165,27 @@ class BookAppointmentsViewModel extends ChangeNotifier {
notifyListeners(); 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 // Group doctors by clinic and hospital
void _groupDoctorsList() { void _groupDoctorsList() {
final clinicMap = <String, List<DoctorsListResponseModel>>{}; final clinicMap = <String, List<DoctorsListResponseModel>>{};

@ -43,7 +43,7 @@ class _SearchDoctorByNameState extends State<SearchDoctorByName> {
body: Column( body: Column(
children: [ children: [
Expanded( Expanded(
child: CollapsingListView( child: CollapsingListView(
title: "Choose Doctor".needTranslation, title: "Choose Doctor".needTranslation,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Padding( child: Padding(
@ -76,7 +76,7 @@ class _SearchDoctorByNameState extends State<SearchDoctorByName> {
) )
: null, : null,
onChange: (value) { onChange: (value) {
// bookAppointmentsViewModel.filterClinics(value!); // bookAppointmentsViewModel.filterClinics(value!);
}, },
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
vertical: ResponsiveExtension(10).h, vertical: ResponsiveExtension(10).h,
@ -89,43 +89,41 @@ class _SearchDoctorByNameState extends State<SearchDoctorByName> {
child: SizedBox( child: SizedBox(
height: 56.h, height: 56.h,
width: 56.h, width: 56.h,
child: DecoratedBox(decoration: RoundedRectangleBorder().toSmoothCornerDecoration( child: DecoratedBox(
color: AppColors.whiteColor, decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
borderRadius: 10.h, color: AppColors.whiteColor,
hasShadow: false, borderRadius: 10.h,
), hasShadow: false,
child: Utils.buildSvgWithAssets(icon: AppAssets.ic_filters, ),
height: 24.h, child: Utils.buildSvgWithAssets(
width: 24.h, ).paddingAll(16.h).onPress((){ icon: AppAssets.ic_filters,
context.read<DoctorFilterViewModel>() height: 24.h,
width: 24.h,
).paddingAll(16.h).onPress(() {
context.read<DoctorFilterViewModel>()
..clearSelection() ..clearSelection()
..clearSearchFilters() ..clearSearchFilters()
..getFiltersFromDoctorList( ..getFiltersFromDoctorList(bookAppointmentsViewModel.doctorsList)
bookAppointmentsViewModel.doctorsList ..setSelections(bookAppointmentsViewModel.selectedFacilityForFilters?.toList(), bookAppointmentsViewModel.selectedRegionForFilters?.toList(),
)..setSelections( bookAppointmentsViewModel.selectedClinicForFilters, bookAppointmentsViewModel.selectedHospitalForFilters, bookAppointmentsViewModel.applyFilters);
bookAppointmentsViewModel.selectedFacilityForFilters?.toList(), Navigator.of(context).push(
bookAppointmentsViewModel.selectedRegionForFilters?.toList(), PageRouteBuilder(
bookAppointmentsViewModel.selectedClinicForFilters, pageBuilder: (context, animation, secondaryAnimation) => DoctorsFilters(), // Replace YourNewPage with your actual page widget
bookAppointmentsViewModel.selectedHospitalForFilters, transitionsBuilder: (context, animation, secondaryAnimation, child) {
bookAppointmentsViewModel.applyFilters) ; const begin = Offset(0.0, 1.0); // Start from the bottom (y=1.0)
Navigator.of(context).push( const end = Offset.zero; // End at the original position (y=0.0)
PageRouteBuilder( final tween = Tween(begin: begin, end: end);
pageBuilder: (context, animation, secondaryAnimation) => DoctorsFilters(), // Replace YourNewPage with your actual page widget final offsetAnimation = animation.drive(tween);
transitionsBuilder: (context, animation, secondaryAnimation, child) {
const begin = Offset(0.0, 1.0); // Start from the bottom (y=1.0)
const end = Offset.zero; // End at the original position (y=0.0)
final tween = Tween(begin: begin, end: end);
final offsetAnimation = animation.drive(tween);
return SlideTransition( return SlideTransition(
position: offsetAnimation, position: offsetAnimation,
child: child, child: child,
); );
}, },
transitionDuration: Duration(milliseconds: 200), // Adjust duration as needed transitionDuration: Duration(milliseconds: 200), // Adjust duration as needed
), ),
); );
}), }),
), ),
), ),
) )
@ -136,9 +134,43 @@ class _SearchDoctorByNameState extends State<SearchDoctorByName> {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ 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 bookAppointmentsVM.isDoctorSearchByNameStarted
? ListView.separated( ? ListView.separated(
padding: EdgeInsets.only(top: 24.h), padding: EdgeInsets.only(top: 20.h),
shrinkWrap: true, shrinkWrap: true,
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
itemCount: bookAppointmentsVM.isDoctorsListLoading ? 5 : bookAppointmentsVM.filteredDoctorList.length, itemCount: bookAppointmentsVM.isDoctorsListLoading ? 5 : bookAppointmentsVM.filteredDoctorList.length,
@ -261,6 +293,7 @@ class _SearchDoctorByNameState extends State<SearchDoctorByName> {
), ),
); );
} }
@override @override
void dispose() { void dispose() {
bookAppointmentsViewModel.doctorsList.clear(); bookAppointmentsViewModel.doctorsList.clear();

Loading…
Cancel
Save