import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/cupertino.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/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/insurance/insurance_view_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.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/shimmer/movies_shimmer_widget.dart';
import 'package:provider/provider.dart';

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

  late InsuranceViewModel insuranceViewModel;

  @override
  Widget build(BuildContext context) {
    insuranceViewModel = Provider.of<InsuranceViewModel>(context);
    return Column(
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            LocaleKeys.insuranceCards.tr(context: context).toText24(isBold: true),
            Utils.buildSvgWithAssets(icon: AppAssets.close_bottom_sheet_icon).onPress(() {
              Navigator.of(context).pop();
            }),
          ],
        ).paddingSymmetrical(24.h, 24.h),
        insuranceViewModel.isInsuranceUpdateDetailsLoading
            ? const MoviesShimmerWidget().paddingSymmetrical(24.h, 24.h)
            : Container(
                // height: 120.h,
                decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
                  color: AppColors.whiteColor,
                  borderRadius: 24,
                ),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    "Haroon Amjad".toText16(weight: FontWeight.w600),
                    "Policy: ${insuranceViewModel.patientInsuranceUpdateResponseModel!.policyNumber}".toText12(isBold: true, color: AppColors.lightGrayColor),
                    SizedBox(height: 8.h),
                    Row(
                      children: [
                        insuranceViewModel.patientInsuranceUpdateResponseModel!.companyName!.toText12(isBold: true),
                        SizedBox(
                          width: 6.h,
                        ),
                        Container(
                          padding: EdgeInsets.symmetric(horizontal: 6.h, vertical: 3.h),
                          decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
                            color: AppColors.infoColor,
                            borderRadius: 50,
                          ),
                          child: insuranceViewModel.patientInsuranceUpdateResponseModel!.subCategory!.toText8(isBold: true, color: AppColors.whiteColor),
                        ),
                      ],
                    ),
                    SizedBox(height: 8.h),
                    Row(
                      children: [
                        Wrap(
                          direction: Axis.horizontal,
                          spacing: 4.h,
                          runSpacing: 4.h,
                          children: [
                            Row(
                              children: [
                                CustomButton(
                                  icon: AppAssets.doctor_calendar_icon,
                                  iconColor: AppColors.blackColor,
                                  iconSize: 13.h,
                                  text: "${LocaleKeys.expiryOn.tr(context: context)} ${insuranceViewModel.patientInsuranceUpdateResponseModel!.effectiveTo}",
                                  onPressed: () {},
                                  backgroundColor: AppColors.greyColor,
                                  borderColor: AppColors.greyColor,
                                  textColor: AppColors.blackColor,
                                  fontSize: 10,
                                  fontWeight: FontWeight.w500,
                                  borderRadius: 12,
                                  padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                                  height: 30.h,
                                ),
                              ],
                            ),
                            Row(
                              children: [
                                CustomButton(
                                  text: "Member ID: ${insuranceViewModel.patientInsuranceUpdateResponseModel!.memberID!}",
                                  onPressed: () {},
                                  backgroundColor: AppColors.greyColor,
                                  borderColor: AppColors.greyColor,
                                  textColor: AppColors.blackColor,
                                  fontSize: 10,
                                  fontWeight: FontWeight.w500,
                                  borderRadius: 12,
                                  padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                                  height: 30.h,
                                ),
                              ],
                            ),
                          ],
                        ),
                      ],
                    ),
                  ],
                ).paddingSymmetrical(16.h, 16.h),
              ).paddingSymmetrical(24.h, 0.h),
        SizedBox(
          height: 24.h,
        ),
        CustomButton(
          icon: AppAssets.insurance_active_icon,
          iconColor: AppColors.whiteColor,
          iconSize: 20.h,
          text: "Update Insurance",
          onPressed: () {},
          backgroundColor: AppColors.successColor,
          borderColor: AppColors.successColor.withOpacity(0.01),
          textColor: AppColors.whiteColor,
          fontSize: 16,
          fontWeight: FontWeight.w500,
          borderRadius: 12,
          padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
          height: 56.h,
        ).paddingSymmetrical(24.h, 0.h),
        SizedBox(
          height: 24.h,
        ),
      ],
    );
  }
}
