import 'dart:ui';

import 'package:flutter_bounceable/flutter_bounceable.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/w_cached_network_image.dart';

import '../../../../food_delivery_client.dart';

class WFoodItem extends StatelessWidget {
  const WFoodItem({
    super.key,
    this.imageHeight,
    this.textStyle1,
    this.textStyle2,
    this.enableTag = false,
  });

  final double? imageHeight;
  final TextStyle? textStyle1;
  final TextStyle? textStyle2;
  final bool enableTag;

  @override
  Widget build(BuildContext context) {
    return Bounceable(
      onTap: () {},
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // CachedNetworkImage(
          //   imageUrl: AppLocaleKeys.imageUrl,
          //   width: 200,
          //   height: 155,
          //   fit: BoxFit.cover,
          //   placeholder: (context, url) => CircularProgressIndicator(),
          //   errorWidget: (context, url, error) => Icon(Icons.error),
          //
          // ),
          SizedBox(
            height: imageHeight ?? 155,
            width: context.w,
            child: Stack(
              children: [
                Positioned.fill(
                  child: WCachedNetworkImage(imageUrl: AppLocaleKeys.imageUrl),
                ),
                // Positioned.fill(
                //   child: CachedNetworkImage(
                //     imageUrl: AppLocaleKeys.imageUrl,
                //     width: 200,
                //     height: 155,
                //     fit: BoxFit.cover,
                //     placeholder: (context, url) =>
                //         Center(child: CircularProgressIndicator.adaptive()),
                //     errorWidget: (context, url, error) => Icon(Icons.error),
                //   ),
                // ),
                Positioned(
                  top: 10,
                  right: 8,
                  left: 0,
                  child: Row(
                    children: [
                      if (enableTag)
                        DecoratedBox(
                          decoration: BoxDecoration(
                            color: AppColors.c34A853,
                            borderRadius: AppUtils.kBorderRadiusTop20Bottom20,
                          ),
                          child: Text(
                            "5 orders until \$8 reward",
                            style: AppTextStyles.size14Medium.copyWith(
                              color: AppColors.cFFFFFF,
                            ),
                          ).paddingOnly(top: 2, bottom: 2, left: 20, right: 40),
                        ),
                      const Spacer(),
                      IconButton(
                        onPressed: () {},
                        icon: SvgPicture.asset(AppIcons.icDislike),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
          8.verticalSpace,
          Row(
            children: [
              Expanded(
                child: Text(
                  "Adenine Kitchen",
                  style: textStyle1 ?? AppTextStyles.size16Medium,
                ),
              ),
              SizedBox(
                height: 24,
                width: 24,
                child: DecoratedBox(
                  decoration: BoxDecoration(
                    color: AppColors.cEEEEEE,
                    borderRadius: AppUtils.kBorderRadius28,
                  ),
                  child: Center(
                    child: Text("4.4", style: AppTextStyles.size12Regular),
                  ),
                ),
              ),
            ],
          ),
          // RichText(
          //   text: TextSpan(
          //     text: "\$0.29 Delivery Fee",
          //     children: [TextSpan(text: "10-25 min")],
          //     style: AppTextStyles.size14Regular.copyWith(
          //       color: AppColors.c6B6B6B,
          //     ),
          //   ),
          // ),
          Row(
            children: [
              Text(
                "\$0.29 Delivery Fee",
                style:
                    textStyle2 ??
                    AppTextStyles.size14Regular.copyWith(
                      color: AppColors.c6B6B6B,
                    ),
              ),
              5.horizontalSpace,
              Icon(Icons.circle, size: 5, color: AppColors.c6B6B6B),
              5.horizontalSpace,
              Text(
                "10-25 min",
                style:
                    textStyle2 ??
                    AppTextStyles.size14Regular.copyWith(
                      color: AppColors.c6B6B6B,
                    ),
              ),
            ],
          ),
        ],
      ).paddingSymmetric(horizontal: 15),
    );
  }
}
