import 'package:flutter/material.dart';
import 'package:em2rp/utils/colors.dart';

/// Widget réutilisable pour créer des chips de filtre avec icône
class CustomFilterChip extends StatelessWidget {
  final String label;
  final Widget? icon;
  final bool isSelected;
  final VoidCallback onSelected;
  final Color selectedColor;
  final Color unselectedTextColor;

  const CustomFilterChip({
    super.key,
    required this.label,
    this.icon,
    required this.isSelected,
    required this.onSelected,
    this.selectedColor = AppColors.rouge,
    this.unselectedTextColor = AppColors.rouge,
  });

  @override
  Widget build(BuildContext context) {
    final color = isSelected ? Colors.white : unselectedTextColor;

    return ChoiceChip(
      label: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          if (icon != null) ...[
            icon!,
            const SizedBox(width: 8),
          ],
          Text(label),
        ],
      ),
      selected: isSelected,
      onSelected: (selected) {
        if (selected) {
          onSelected();
        }
      },
      selectedColor: selectedColor,
      labelStyle: TextStyle(
        color: color,
        fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
      ),
    );
  }
}

