import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_export.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/medical_file/models/patient_medical_response_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/presentation/medical_report/medical_reports_page.dart';
import 'package:hmg_patient_app_new/presentation/monthly_report/monthly_report.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';

class MedicalReportCard extends StatelessWidget {
  final bool isLoading;
  final List<PatientMedicalReportResponseModel> listRequest;
  final List<PatientMedicalReportResponseModel> listReady;
  final VoidCallback? onViewDetails;

  const MedicalReportCard({
    super.key,
    required this.isLoading,
    required this.listRequest,
    required this.listReady,
    this.onViewDetails,
  });



  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
        color: AppColors.whiteColor,
        borderRadius: 24,
        hasShadow: true,
      ),
      child: Padding(
        padding: EdgeInsets.all(16.h),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            LocaleKeys.medicalReportNew.tr().toText18(
              isBold: true,
              weight: FontWeight.w700,
            ).toShimmer2(isShow: isLoading),
            SizedBox(height: 12.h),
            Wrap(
              spacing: 8.w,
              runSpacing: 8.h,
              children: [
                if ( listRequest.isNotEmpty )
                  AppCustomChipWidget(
                    labelText: '${listRequest.length.toString().padLeft(2, '0')} ${LocaleKeys.requested.tr()}',
                    icon: AppAssets.document,
                    iconColor: AppColors.alertColor,
                    textColor: AppColors.alertColor,
                    backgroundColor: AppColors.warningColorYellow.withOpacity(.2),
                    iconSize: 14.w,
                  ),
                if (listReady.isNotEmpty)
                  AppCustomChipWidget(
                    labelText: '${listReady.length.toString().padLeft(2, '0')} ${LocaleKeys.readyToDownload.tr()}',
                    icon: AppAssets.sucess,
                    iconColor: AppColors.successColor,
                    textColor: AppColors.successColor,
                    backgroundColor: AppColors.switchBackgroundColor,
                    iconSize: 14.w,
                  ),
              ],
            ).toShimmer2(isShow: isLoading),
            SizedBox(height: 16.h),
            CustomButton(
              text: LocaleKeys.viewDetails.tr(),
              icon: AppAssets.report,
              borderWidth: 0,
              isDisabled: false,
              onPressed: (){
                Navigator.of(context).push(
                          CustomPageRoute(
                            page: MedicalReportsPage(),
                          ),
                        );
              },
              backgroundColor: AppColors.lightRedButtonColor,
              borderColor: AppColors.lightRedButtonColor,
              textColor: AppColors.primaryRedColor,
              iconColor: AppColors.primaryRedColor,
              fontSize: 14.f,
              // fontWeight: FontWeight.w600,
              isBold: true,
              borderRadius: 12.r,
              height: 40.h,
            ).toShimmer2(isShow: isLoading),
          ],
        ),
      ),
    );
  }
}
