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/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/facility_selection.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/chip/app_custom_chip_widget.dart';

class TypeSelectionWidget extends StatelessWidget {
  final String hmcCount;
  final String hmgCount;
  final FacilitySelection selectedFacility;
  final Function(FacilitySelection) onitemClicked;

  const TypeSelectionWidget(
      {super.key,
      required this.hmcCount,
      required this.hmgCount,
      required this.onitemClicked,
      required this.selectedFacility});

  @override
  Widget build(BuildContext context) {

    return Row(
      spacing: 8,
      mainAxisSize: MainAxisSize.max,
      children: [
        AppCustomChipWidget(
          labelText: LocaleKeys.all.tr(context: context),
          shape: RoundedRectangleBorder(
              side: BorderSide(
                color: selectedFacility == FacilitySelection.ALL
                    ? AppColors.errorColor
                    : AppColors.chipBorderColorOpacity20,
                width: 1,
              ),
              borderRadius: BorderRadius.circular(10)),
          backgroundColor:
          selectedFacility == FacilitySelection.ALL
              ?AppColors.secondaryLightRedColor: AppColors.whiteColor,
          textColor:  selectedFacility == FacilitySelection.ALL
              ? AppColors.errorColor:AppColors.blackColor
          ,
        ).onPress((){
          onitemClicked(FacilitySelection.ALL);
        }),
        Visibility(
          visible: hmgCount != "0",
          child: AppCustomChipWidget(
            icon: AppAssets.hmg,
            iconHasColor: false,
            applyThemeColor: false,
            labelText: LocaleKeys.hmgHospitals.tr(context: context),
            shape: RoundedRectangleBorder(
                side: BorderSide(
                  color: selectedFacility == FacilitySelection.HMG
                      ? AppColors.errorColor
                      : AppColors.chipBorderColorOpacity20,
                  width: 1,
                ),
                borderRadius: BorderRadius.circular(10)),
            backgroundColor:
            selectedFacility == FacilitySelection.HMG
                ?AppColors.secondaryLightRedColor: AppColors.whiteColor,
            textColor:  selectedFacility == FacilitySelection.HMG
                ? AppColors.errorColor
                : AppColors.blackColor,
          ).onPress((){
            onitemClicked(FacilitySelection.HMG);
          }),
        ),
        Visibility(
          visible: hmcCount != "0",
          child: AppCustomChipWidget(
            icon: AppAssets.hmc,
            iconHasColor: false,
            applyThemeColor: false,
            labelText: LocaleKeys.hmcMedicalClinic.tr(context: context),
            shape: RoundedRectangleBorder(
                side: BorderSide(
                  color: selectedFacility == FacilitySelection.HMC
                      ? AppColors.errorColor
                      : AppColors.chipBorderColorOpacity20,
                  width: 1,
                ),
                borderRadius: BorderRadius.circular(10)),
            backgroundColor:
            selectedFacility == FacilitySelection.HMC
                ?AppColors.secondaryLightRedColor: AppColors.whiteColor,
            textColor: selectedFacility == FacilitySelection.HMC
                ? AppColors.errorColor
                : AppColors.blackColor,
          ).onPress((){
            onitemClicked(FacilitySelection.HMC);
          }),
        ),
      ],
    );
  }
}
