import 'package:easy_localization/easy_localization.dart' show tr, StringTranslateExtension;
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.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/habib_wallet/habib_wallet_view_model.dart';
import 'package:hmg_patient_app_new/features/my_appointments/appointment_via_region_viewmodel.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/facility_selection.dart';
import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.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/presentation/appointments/widgets/hospital_bottom_sheet/type_selection_widget.dart';
import 'package:hmg_patient_app_new/presentation/habib_wallet/widgets/hospital_list_item.dart';
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
import 'package:hmg_patient_app_new/theme/colors.dart' show AppColors;
import 'package:hmg_patient_app_new/widgets/input_widget.dart';
import 'package:provider/provider.dart';

class SelectHospitalBottomSheet extends StatelessWidget {
  late HabibWalletViewModel habibWalletVM;
  final TextEditingController searchText = TextEditingController();

  SelectHospitalBottomSheet({super.key});

  @override
  Widget build(BuildContext context) {
    habibWalletVM = Provider.of<HabibWalletViewModel>(context, listen: false);
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        // Text(
        //   LocaleKeys.selectHospital.tr(),
        //   style: TextStyle(
        //     fontSize: 21,
        //     fontWeight: FontWeight.w600,
        //     color: AppColors.blackColor,
        //   ),
        // ),
        Text(
          "Please select the hospital you want to make an advance payment for.".needTranslation,
          style: TextStyle(
            fontSize: 16,
            fontWeight: FontWeight.w500,
            color: AppColors.greyTextColor,
          ),
        ),
        SizedBox(height: 16.h),
        // TextInputWidget(
        //   labelText: LocaleKeys.search.tr(),
        //   hintText: "Search Hospital".tr(),
        //   controller: searchText,
        //   onChange: (value) {
        //     // appointmentsViewModel.filterHospitalListByString(value, regionalViewModel.selectedRegionId , regionalViewModel.selectedFacilityType ==
        //     //     FacilitySelection.HMG.name);
        //   },
        //   isEnable: true,
        //   prefix: null,
        //   autoFocus: false,
        //   isBorderAllowed: false,
        //   keyboardType: TextInputType.text,
        //   isAllowLeadingIcon: true,
        //   selectionType: SelectionTypeEnum.search,
        //   padding: EdgeInsets.symmetric(
        //     vertical: ResponsiveExtension(10).h,
        //     horizontal: ResponsiveExtension(15).h,
        //   ),
        // ),
        // SizedBox(height: 24.h),
        // TypeSelectionWidget(
        //   hmcCount: "0",
        //   hmgCount: "0",
        // ),
        // SizedBox(height: 21.h),
        SizedBox(
          height: MediaQuery.sizeOf(context).height * .4,
          child: ListView.separated(
              itemBuilder: (_, index) {
                return HospitalListItemAdvancePayment(
                  hospitalModel: habibWalletVM.advancePaymentHospitals[index],
                  isLocationEnabled: false,
                ).onPress(() {
                  habibWalletVM.setSelectedHospital(habibWalletVM.advancePaymentHospitals[index]);
                  Navigator.of(context).pop();
                });
              },
              separatorBuilder: (_, __) => SizedBox(
                    height: 16.h,
                  ),
              itemCount: habibWalletVM.advancePaymentHospitals.length),
        )
      ],
    );
  }
}
