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

class ListItemWithOutCounter extends StatelessWidget {
  const ListItemWithOutCounter({
    super.key,
    required this.child,
    required this.secondChild,
    required this.labelColor,
    required this.labelIcon,
    required this.onTap,
    required this.selected,
    this.labelIconColor = AppColor.mediumGreyDarkHover,
  });

  final Widget child;
  final Widget secondChild;
  final Color labelColor;
  final String labelIcon;
  final Color? labelIconColor;
  final VoidCallback onTap;
  final bool selected;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        width: Get.width,
        margin: const EdgeInsets.fromLTRB(0, 0, 10, 0),
        decoration: BoxDecoration(
          color: labelColor,
          borderRadius: BorderRadius.circular(8),
          border: Border.all(width: 1, color: AppColor.lightGreyNormalHover),
        ),
        child: AnimatedSize(
          duration: Duration(milliseconds: 400),
          alignment: Alignment.center,
          child: AnimatedSize(
            duration: Duration(milliseconds: 300),
            child: Container(
              width: Get.width - 30,
              alignment: Alignment.center,
              decoration: BoxDecoration(
                color: Colors.transparent,
                borderRadius: BorderRadius.circular(8),
              ),
              child: Row(
                children: [
                  Expanded(
                    child: AnimatedCrossFade(
                      alignment: Alignment.center,
                      firstChild: Container(
                        height: 75,
                        decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.only(
                            bottomLeft: Radius.zero,
                            bottomRight: Radius.circular(8),
                            topLeft: Radius.zero,
                            topRight: Radius.circular(8),
                          ),
                        ),
                        clipBehavior: Clip.antiAlias,
                        child: child,
                      ),
                      secondChild: Container(
                        padding: EdgeInsets.all(8),
                        clipBehavior: Clip.antiAlias,
                        decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.circular(8),
                        ),
                        child: secondChild,
                      ),
                      crossFadeState: selected
                          ? CrossFadeState.showSecond
                          : CrossFadeState.showFirst,
                      duration: Duration(milliseconds: 300),
                    ),
                  ),
                  Visibility(
                    visible: selected==false,
                    child: Container(
                      width: 20,
                      child: Center(
                        child: SvgGenImage.vec(labelIcon).svg(
                          width: 16.w,
                          height: 16.h,
                          colorFilter: ColorFilter.mode(labelColor, BlendMode.srcIn),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}

