import 'package:cached_network_image/cached_network_image.dart';
import 'package:e_commerce_training/res/R.dart';
import 'package:flutter/material.dart';

class ShoppingBasketListItem extends StatefulWidget {
  //final Product product;
  final int count;
  final VoidCallback remove;
  final VoidCallback add;

  ShoppingBasketListItem({required this.count, required this.remove, required this.add});

  @override
  ShoppingBasketListItemState createState() {
    return new ShoppingBasketListItemState();
  }
}

class ShoppingBasketListItemState extends State<ShoppingBasketListItem> {
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () => Navigator.of(context).push(MaterialPageRoute(builder: (ctx) => Container())),
      child: Column(
        children: <Widget>[
          Row(
            mainAxisSize: MainAxisSize.max,
            children: <Widget>[
              CachedNetworkImage(
                imageUrl: 'widget.product.imageUrl',
                width: 100.0,
                height: 100.0,
                fit: BoxFit.cover,
              ),
              Expanded(
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      // Text(widget.product.name),
                      // Text("${widget.product.price.toString().split(".")[0]}" +
                      //     " đ")
                    ],
                  ),
                ),
              ),
              Container(
                margin: EdgeInsets.only(right: 16.0),
                decoration: BoxDecoration(
                    border: Border.all(color: R.color.lightBlack, width: 2.0),
                    borderRadius: BorderRadius.circular(64.0)),
                child: Row(
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    IconButton(
                      icon: Icon(
                        Icons.remove_circle_outline,
                        color: R.color.lightBlack,
                      ),
                      onPressed: () => widget.remove,
                    ),
                    Text(
                      "${widget.count}",
                      style: TextStyle(color: R.color.lightBlack),
                    ),
                    IconButton(
                      icon: Icon(
                        Icons.add_circle_outline,
                        color: R.color.lightBlack,
                      ),
                      onPressed: () => widget.add,
                    ),
                  ],
                ),
              ),
            ],
          ),
          Divider(
            height: 0.0,
          )
        ],
      ),
    );
  }
}
