import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_staggered_animations/flutter_staggered_animations.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/contact_us/contact_us_view_model.dart';
import 'package:hmg_patient_app_new/features/medical_file/medical_file_view_model.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/appointment_card.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
import 'package:provider/provider.dart';

class FeedbackAppointmentSelection extends StatelessWidget {
  FeedbackAppointmentSelection({super.key});

  late MedicalFileViewModel medicalFileViewModel;
  late ContactUsViewModel contactUsViewModel;

  @override
  Widget build(BuildContext context) {
    medicalFileViewModel = Provider.of<MedicalFileViewModel>(context, listen: false);
    contactUsViewModel = Provider.of<ContactUsViewModel>(context, listen: false);
    return CollapsingListView(
      title: LocaleKeys.feedback.tr(),
      isClose: true,
      child: Column(
        children: [
          ListView.separated(
            padding: EdgeInsets.only(top: 24.h),
            shrinkWrap: true,
            physics: NeverScrollableScrollPhysics(),
            itemCount: medicalFileViewModel.patientMedicalReportAppointmentHistoryList.length,
            itemBuilder: (context, index) {
              return AnimationConfiguration.staggeredList(
                position: index,
                duration: const Duration(milliseconds: 500),
                child: SlideAnimation(
                  verticalOffset: 100.0,
                  child: FadeInAnimation(
                    child: AnimatedContainer(
                      duration: Duration(milliseconds: 300),
                      curve: Curves.easeInOut,
                      decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.h, hasShadow: true),
                      child: AppointmentCard(
                        patientAppointmentHistoryResponseModel: medicalFileViewModel.patientMedicalReportAppointmentHistoryList[index],
                        myAppointmentsViewModel: Provider.of<MyAppointmentsViewModel>(context, listen: false),
                        bookAppointmentsViewModel: Provider.of<BookAppointmentsViewModel>(context, listen: false),
                        medicalFileViewModel: medicalFileViewModel,
                        contactUsViewModel: contactUsViewModel,
                        isLoading: false,
                        isFromHomePage: false,
                        isFromMedicalReport: true,
                        isForFeedback: true,
                      ),
                    ).paddingSymmetrical(24.h, 0.h),
                  ),
                ),
              );
            },
            separatorBuilder: (BuildContext cxt, int index) => SizedBox(height: 16.h),
          ),
          SizedBox(height: 24.h),
        ],
      ),
    );
  }
}
