import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/book_appointments/models/LaserCategoryType.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:smooth_corner/smooth_corner.dart' show SmoothRectangleBorder;

class BodyTypeListing extends StatelessWidget {
  final List<LaserCategoryType> availableBodyArea;
  final Function(int) onCategoryChanged;
  final int selectedBodyAreaIndex;

  const BodyTypeListing(
      {super.key,
      required this.availableBodyArea,
      required this.onCategoryChanged,
      required this.selectedBodyAreaIndex});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 56.h,
      child: Row(
        children: [
          Expanded(
              child: ListView.separated(
                scrollDirection: Axis.horizontal,
                  itemCount: availableBodyArea.length,
                  separatorBuilder: (_, index) => SizedBox(
                        width: 8.h,
                      ),
                  itemBuilder: (_, index) => AppCustomChipWidget(
                      backgroundColor: index == selectedBodyAreaIndex
                          ? AppColors.chipSecondaryLightRedColor
                          : AppColors.whiteColor,
                      textColor: index == selectedBodyAreaIndex
                          ? AppColors.chipPrimaryRedBorderColor
                          : AppColors.blackColor,
                      labelText: availableBodyArea[index].title.tr(),
                      iconHasColor: false,
                      iconColor: index == selectedBodyAreaIndex
                          ? AppColors.chipPrimaryRedBorderColor
                          : AppColors.blackColor,
                      iconSize: 16,
                  labelPadding: EdgeInsetsDirectional.only(start: 8.w, end: 8.w),
                  padding: EdgeInsets.symmetric(vertical: 16.h, horizontal: 12.w),
                  deleteIconSize: Size(18.w, 18.h),
                  shape: SmoothRectangleBorder(
                    borderRadius: BorderRadius.circular(10.r),
                    smoothness: 10,
                        side: BorderSide(
                            color: index == selectedBodyAreaIndex
                                ? AppColors.chipPrimaryRedBorderColor
                                : AppColors.borderGrayColor,
                            width: 1),
                  )).onPress(
                () => onCategoryChanged(index),
              ),
            ),
          )
        ],
      ),
    );
  }
}
