import 'package:easy_localization/easy_localization.dart'
    show tr, StringTranslateExtension;
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/book_appointments/book_appointments_view_model.dart';
import 'package:hmg_patient_app_new/features/doctor_filter/doctor_filter_view_model.dart';
import 'package:hmg_patient_app_new/features/my_appointments/appointment_via_region_viewmodel.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/presentation/appointments/widgets/hospital_bottom_sheet/hospital_list_items.dart';
import 'package:hmg_patient_app_new/theme/colors.dart' show AppColors;
import 'package:provider/provider.dart';

class HospitalBottomSheetBodyForDoctorFilter extends StatelessWidget {
  late BookAppointmentsViewModel appointmentsViewModel;
  late AppointmentViaRegionViewmodel regionalViewModel;
  final TextEditingController searchText = TextEditingController();

  HospitalBottomSheetBodyForDoctorFilter({super.key});

  @override
  Widget build(BuildContext context) {
    appointmentsViewModel = Provider.of<BookAppointmentsViewModel>(context);
    regionalViewModel = Provider.of<AppointmentViaRegionViewmodel>(context);
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          LocaleKeys.selectHospital.tr(),
          style: TextStyle(
            fontSize: 21,
            fontWeight: FontWeight.w600,
            color: AppColors.blackColor,
          ),
        ),
        SizedBox(height: 24.h),
        SizedBox(
          height: MediaQuery.sizeOf(context).height * .4,
          child: ListView.separated(
              itemBuilder: (_, index)
              {
                var hospital = appointmentsViewModel.searchedPatientDoctorAppointmentHospitalsList[index];
                return HospitalListItem(
                hospitalData: hospital,
                isLocationEnabled: appointmentsViewModel.isLocationEnabled(),
              ).onPress(() {
                regionalViewModel.setHospitalModel(hospital);
                context.read<DoctorFilterViewModel>().setSelectedHospital(hospital);
                 Navigator.pop(context);
                });},
              separatorBuilder: (_, __) => SizedBox(
                    height: 16.h,
                  ),
              itemCount: appointmentsViewModel.searchedPatientDoctorAppointmentHospitalsList?.length ?? 0),
        )
      ],
    );
  }
}
