import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/color_manager.dart';

class ConditionToggle extends StatelessWidget {
  final String? currentCondition;
  final void Function(String condition) onChanged;

  const ConditionToggle({
    required this.onChanged,
    this.currentCondition,
    super.key,
  });

  static const _conditions = ["<", "==", ">"];

  @override
  Widget build(BuildContext context) {
    return ToggleButtons(
      onPressed: (index) => onChanged(_conditions[index]),
      borderRadius: const BorderRadius.all(Radius.circular(8)),
      selectedBorderColor: ColorsManager.primaryColorWithOpacity,
      selectedColor: Colors.white,
      fillColor: ColorsManager.primaryColorWithOpacity,
      color: ColorsManager.primaryColorWithOpacity,
      constraints: const BoxConstraints(
        minHeight: 40.0,
        minWidth: 40.0,
      ),
      isSelected: _conditions.map((c) => c == (currentCondition ?? "==")).toList(),
      children: _conditions.map((c) => Text(c)).toList(),
    );
  }
}
