import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';

Widget customChip({
  bool isSelected = false,
  required String title,
  required int index,
  required Function(int) onTap,
}) {
  return GestureDetector(
    onTap: () {
      onTap.call(index);
    },
    child: Container(
      height: 32.h,
      padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 8.h),
      clipBehavior: Clip.antiAlias,
      decoration: BoxDecoration(
        color: AppColor.whiteGreyNormal,
        borderRadius: BorderRadius.circular(8),
        border: Border.all(
          width: 1,
          color: isSelected ? AppColor.blueNormal : AppColor.blackLightActive,
        ),
      ),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.center,

        children: [
          SizedBox(
            width: 12.w,
            height: 12.h,
            child: Transform.scale(
              scale: 0.70,
              child: Checkbox(
                value: isSelected,
                side: BorderSide(color: AppColor.whiteDarkHover, width: 1),
                materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                visualDensity: VisualDensity.compact,
                overlayColor: WidgetStateProperty.all<Color>(AppColor.blueNormal),
                fillColor: WidgetStateProperty.resolveWith((states) {
                  if (states.contains(WidgetState.selected)) {
                    return AppColor.blueNormal;
                  } else {
                    return AppColor.whiteGreyNormal;
                  }
                }),

                onChanged: (value) {
                  onTap.call(index);
                },
              ),
            ),
          ),
          SizedBox(width: 8.w),
          Text(
            title,
            textAlign: TextAlign.center,
            style: AppFonts.yekan12.copyWith(
              color: isSelected ? AppColor.blueNormal : AppColor.whiteDarkHover,
            ),
          ),
        ],
      ),
    ),
  );
}
