import 'package:flutter/cupertino.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/my_appointments/models/resp_models/patient_appointment_history_response_model.dart';
import 'package:hmg_patient_app_new/presentation/appointments/widgets/appointment_doctor_card.dart';

class AppointmentBottomSheet extends StatelessWidget{


  final Function(PatientAppointmentHistoryResponseModel) onAppointmentSelection;
  final List<PatientAppointmentHistoryResponseModel> list;

  const AppointmentBottomSheet({super.key, required this.onAppointmentSelection, required this.list});

  @override
  Widget build(BuildContext context) => getAppointList(list);

  Widget getAppointList( List<PatientAppointmentHistoryResponseModel> list) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Expanded(
          child: ListView.separated(
            padding: EdgeInsets.only(top: 24.h),
            shrinkWrap: true,
            physics: BouncingScrollPhysics(),
            itemCount: list.length,
            itemBuilder: (context, index) {
              PatientAppointmentHistoryResponseModel item = list[index];
              return  AppointmentDoctorCard(
                renderWidgetForERDisplay: true,
                patientAppointmentHistoryResponseModel: item,
                onAskDoctorTap: () {},
                onCancelTap: () async {},
                onRescheduleTap: () async {},
              ).onPress((){
                onAppointmentSelection(item);
              });
            },
            separatorBuilder: (BuildContext cxt, int index) => SizedBox(height: 16.h),
          ),
        ),
        SizedBox(height: 24.h),
      ],
    );
  }


}