import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../../../app/app.dart';
import '../controller.dart';

class WishlistCartItem extends StatelessWidget {
  final WishlistModel model;
  WishlistCartItem({
    required this.model,
  });

  @override
  Widget build(BuildContext context) {
    return GetBuilder<WishlistController>(
      init: WishlistController(),
      builder: (cc) => GestureDetector(
        onTap: () => Get.to(() => ProductDetailsPage(model: model.product)),
        child: Container(
          padding: const EdgeInsets.symmetric(vertical: 8),
          child: Column(
            children: [
              Container(
                constraints: BoxConstraints(
                  minHeight: 90.h,
                ),
                child: Row(
                  children: [
                    // image
                    SizedBox(
                      width: 90.w,
                      height: 90.h,
                      child: Container(
                        padding: EdgeInsets.all(2),
                        decoration: BoxDecoration(
                          color: Color(0xFFF5F6F9),
                          borderRadius: BorderRadius.circular(4),
                        ),
                        child: cachedImageNetwork(
                          getImagePath(model.product.images),
                          BoxFit.fill,
                          const BorderRadius.all(Radius.circular(4.0)),
                          90.w,
                          90.h,
                        ),
                      ),
                    ),
                    SizedBox(width: 20),
                    Expanded(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            model.product.name,
                            style: TextStyle(fontWeight: FontWeight.normal, fontSize: 13.sp),
                            maxLines: 4,
                            overflow: TextOverflow.ellipsis,
                          ),
                          SizedBox(height: 8.h),
                          Text(''),
                          SizedBox(height: 8.h),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceAround,
                            children: [
                              Text(model.product.formattedPrice, style: new TextStyle(color: ThemeColor.mainColor, fontSize: 11.sp)),
                              Spacer(),
                              CircularSplashButton(
                                icon: 'assets/icons/love_icon.svg',
                                callback: () => cc.onWishlistTapped(context, model.product.id),
                              ),
                            ],
                          )
                        ],
                      ),
                    )
                  ],
                ),
              ),
              AppTheme.appColorDivider,
            ],
          ),
        ),
      ),
    );
  }
}
