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/book_appointments/book_appointments_view_model.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/facility_selection.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';
import 'package:provider/provider.dart' show Consumer;

class TypeSelectionWidget extends StatelessWidget {
  final String hmcCount;
  final String hmgCount;

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

  @override
  Widget build(BuildContext context) {
    return Consumer<BookAppointmentsViewModel>(
      builder: (_, data, __) => Row(
        spacing: 8,
        mainAxisSize: MainAxisSize.max,
        children: [
          AppCustomChipWidget(
            labelText: "All Facilities",
            shape: RoundedRectangleBorder(
                side: BorderSide(
                  color: data.currentlySelectedFacility == FacilitySelection.ALL
                      ? AppColors.errorColor
                      : AppColors.chipBorderColorOpacity20,
                  width: 1,
                ),
                borderRadius: BorderRadius.circular(10)),
            backgroundColor:
                data.currentlySelectedFacility == FacilitySelection.ALL
                    ? AppColors.secondaryLightRedColor
                    : AppColors.whiteColor,
            textColor: data.currentlySelectedFacility == FacilitySelection.ALL
                ? AppColors.errorColor
                : AppColors.blackColor,
          ).onPress((){
            data.setSelectedFacility(FacilitySelection.ALL);
          }),
          AppCustomChipWidget(
            icon: AppAssets.hmg,
            iconHasColor: false,
            labelText: "Hospitals",
            shape: RoundedRectangleBorder(
                side: BorderSide(
                  color: data.currentlySelectedFacility == FacilitySelection.HMG
                      ? AppColors.errorColor
                      : AppColors.chipBorderColorOpacity20,
                  width: 1,
                ),
                borderRadius: BorderRadius.circular(10)),
            backgroundColor:
                data.currentlySelectedFacility == FacilitySelection.HMG
                    ? AppColors.secondaryLightRedColor
                    : AppColors.whiteColor,
            textColor: data.currentlySelectedFacility == FacilitySelection.HMG
                ? AppColors.errorColor
                : AppColors.blackColor,
          ).onPress((){
            data.setSelectedFacility(FacilitySelection.HMG);
          }),
          AppCustomChipWidget(
            icon: AppAssets.hmc,
            iconHasColor: false,
            labelText: "Medical Centers",
            shape: RoundedRectangleBorder(
                side: BorderSide(
                  color: data.currentlySelectedFacility == FacilitySelection.HMC
                      ? AppColors.errorColor
                      : AppColors.chipBorderColorOpacity20,
                  width: 1,
                ),
                borderRadius: BorderRadius.circular(10)),
            backgroundColor:
            data.currentlySelectedFacility == FacilitySelection.HMC
                ? AppColors.secondaryLightRedColor
                : AppColors.whiteColor,
            textColor: data.currentlySelectedFacility == FacilitySelection.HMC
                ? AppColors.errorColor
                : AppColors.blackColor,
          ).onPress((){
            data.setSelectedFacility(FacilitySelection.HMC);
          }),
        ],
      ),
    );
  }
}
