import 'package:flutter/material.dart';
import 'package:krow/core/presentation/gen/assets.gen.dart';
import 'package:krow/core/presentation/styles/theme.dart';

enum CheckBoxStyle {
  green,
  black,
  red,
}

class KWCheckBox extends StatelessWidget {
  final bool value;
  final CheckBoxStyle? style;

  const KWCheckBox({
    super.key,
    required this.value,
    this.style = CheckBoxStyle.green,
  });

  Color get _color {
    switch (style!) {
      case CheckBoxStyle.green:
        return value ? AppColors.statusSuccess : Colors.white;
      case CheckBoxStyle.black:
        return value ? AppColors.bgColorDark : Colors.white;
      case CheckBoxStyle.red:
        return value ? AppColors.statusError : Colors.white;
    }
  }

  Widget get _icon {
    switch (style!) {
      case CheckBoxStyle.green:
      case CheckBoxStyle.black:
        return Assets.images.icons.checkBox.check.svg();
      case CheckBoxStyle.red:
        return Assets.images.icons.checkBox.x.svg();
    }
  }

  @override
  Widget build(BuildContext context) {
    return AnimatedContainer(
      duration: const Duration(milliseconds: 200),
      width: 16,
      height: 16,
      decoration: BoxDecoration(
        color: _color,
        borderRadius: BorderRadius.circular(4),
        border: value
            ? null
            : Border.all(color: AppColors.grayTintStroke, width: 1),
      ),
      child: Center(
        child: value ? _icon : null,
      ),
    );
  }
}
