import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

class GoodsShareEdit extends StatelessWidget {
  final String message;
  final VoidCallback onEditorClick;
  final VoidCallback onCopyClick;

  final String imgCheck;
  final String imgCheckSelected;
  final String imgEdit;
  final String imgCopy;

  const GoodsShareEdit(this.message,
      {Key key,
      this.onEditorClick,
      this.onCopyClick,
      this.imgCheck,
      this.imgCheckSelected,
      this.imgEdit,
      this.imgCopy})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(left: 10, right: 10),
      // padding: EdgeInsets.only(left: 16, top: 10, right: 16, bottom: 10),
      decoration: BoxDecoration(
          color: Color(0xfff8f8f8), borderRadius: BorderRadius.circular(10)),
      width: double.infinity,
      child: Column(
        children: <Widget>[
          Padding(
            padding:
                const EdgeInsets.only(left: 16, top: 10, right: 16, bottom: 10),
            child: Text(
              message,
              style: TextStyle(
                fontSize: 11,
                fontWeight: FontWeight.bold,
              ),
            ),
          ),
          // Container(
          //   padding:
          //       const EdgeInsets.only(left: 16, top: 6, bottom: 6, right: 16),
          //   width: double.infinity,
          //   child: Wrap(
          //     spacing: 10,
          //     runSpacing: 6,
          //     children: <Widget>[
          //       GoodsShareCheckButton(
          //         '标题',
          //         imgIcon: this.imgCheck,
          //         imgIconSelected: this.imgCheckSelected,
          //         isSelected: false,
          //       ),
          //       GoodsShareCheckButton(
          //         '收益',
          //         imgIcon: this.imgCheck,
          //         imgIconSelected: this.imgCheckSelected,
          //         isSelected: false,
          //       ),
          //       GoodsShareCheckButton(
          //         '邀请码',
          //         imgIcon: this.imgCheck,
          //         imgIconSelected: this.imgCheckSelected,
          //         isSelected: false,
          //       ),
          //       GoodsShareCheckButton(
          //         '链接',
          //         imgIcon: this.imgCheck,
          //         imgIconSelected: this.imgCheckSelected,
          //         isSelected: false,
          //       ),
          //     ],
          //   ),
          // ),
          // Container(
          //   width: double.infinity,
          //   height: 0.5,
          //   color: Color(0xffececec),
          // ),
          // Container(
          //   height: 44,
          //   child: Row(
          //     children: <Widget>[
          //       Expanded(
          //         child: GestureDetector(
          //           child: Container(
          //             color: Colors.transparent,
          //             child: GoodsShareCheckButton(
          //               '编辑模版',
          //               isSelected: true,
          //             ),
          //           ),
          //           onTap: onEditorClick,
          //         ),
          //       ),
          //       Container(
          //         width: 0.5,
          //         height: 20,
          //         color: Color(0xffececec),
          //       ),
          //       Expanded(
          //         child: GestureDetector(
          //           child: Container(
          //             color: Colors.transparent,
          //             child: GoodsShareCheckButton(
          //               '复制文案',
          //               isSelected: false,
          //             ),
          //           ),
          //           onTap: onCopyClick,
          //         ),
          //       ),
          //     ],
          //   ),
          // )
        ],
      ),
    );
  }
}

class GoodsShareCheckButton extends StatelessWidget {
  final String title;
  final bool isSelected;
  final String imgIcon;
  final String imgIconSelected;

  const GoodsShareCheckButton(this.title,
      {Key key,
      this.isSelected = true,
      this.imgIcon = '',
      this.imgIconSelected = ''})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return UnconstrainedBox(
      child: Row(
        children: <Widget>[
          imgIcon == null || imgIcon == ''
              ? Container()
              : Container(
                  width: 16,
                  height: 16,
                  margin: EdgeInsets.only(right: 6),
                  child: CachedNetworkImage(
                    imageUrl: isSelected ? imgIconSelected : imgIcon,
                  ),
                ),
          Text(
            title,
            style: TextStyle(
                fontSize: 11,
                color: isSelected ? Color(0xffff4242) : Color(0xff333333)),
          ),
        ],
      ),
    );
  }
}
