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

class BrandTabBarView extends StatefulWidget {
  final TabController tabController;

  const BrandTabBarView({Key key, this.tabController}) : super(key: key);

  @override
  _BrandTabBarViewState createState() => _BrandTabBarViewState();
}

class _BrandTabBarViewState extends State<BrandTabBarView> {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: <Widget>[
          Container(
            margin: EdgeInsets.only(left: 10, right: 10),
            decoration: BoxDecoration(
              color: Colors.white,
            ),
            child: Padding(
              padding: EdgeInsets.only(top: 8, bottom: 8),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: buildSelectItem(),
              ),
            ),
          ),
          Divider(
            height: 2,
            endIndent: 32,
            indent: 32,
          ),
          Expanded(
              child: ListView.builder(
                  padding: EdgeInsets.all(0),
                  itemCount: 10,
                  itemBuilder: _buildGoods))
        ],
      ),
    );
  }

  buildSelectItem() {
    List<Widget> listWidget = List();
    for (var index = 0; index < 3; index++) {
      listWidget.add(Text("价格"));
    }
    return listWidget;
  }

  Widget _buildGoods(BuildContext context, int index) {
    return Container(
      decoration: BoxDecoration(color: Colors.white),
      margin: EdgeInsets.only(left: 10, right: 10, bottom: 10),
      padding: EdgeInsets.all(10),
      child: Row(
        children: <Widget>[
          Container(),
          Container(
            width: 82,
            height: 82,
            decoration: BoxDecoration(
                image: DecorationImage(
                    image: CachedNetworkImageProvider(
                        "https://alipic.lanhuapp.com/SketchPngd755e6f62dfaf7bae4da8bf384a5ef25bde99ae5e4f34424c5d404c805775bc1"))),
          ),
          SizedBox(
            width: 10,
          ),
          Expanded(
              child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Text(
                "王一博同款高露洁氨基酸精华漱口水双支装",
                style: TextStyle(
                    color: HexColor.fromHex("#FF333333"),
                    fontSize: 13,
                    fontWeight: FontWeight.w500),
              ),
              SizedBox(
                height: 8,
              ),
              Row(
                crossAxisAlignment: CrossAxisAlignment.end,
                children: <Widget>[
                  Container(
                    color: Colors.red,
                    child: Text(
                      "到手价",
                      style: TextStyle(
                          color: HexColor.fromHex("#FFFFFF"), fontSize: 12),
                    ),
                  ),
                  SizedBox(
                    width: 4,
                  ),
                  Padding(
                    padding: EdgeInsets.only(bottom: 1),
                    child: Text(
                      "¥",
                      style: TextStyle(
                          color: HexColor.fromHex("#FFFF4242"), fontSize: 11),
                    ),
                  ),
                  Text(
                    "89.98",
                    style: TextStyle(
                        color: HexColor.fromHex("#FFFF4242"), fontSize: 18),
                  ),
                  SizedBox(
                    width: 4,
                  ),
                  Text(
                    "¥89.98",
                    style: TextStyle(
                        color: HexColor.fromHex("#FFACACAC"),
                        fontSize: 10,
                        decoration: TextDecoration.lineThrough),
                  ),
                ],
              ),
              SizedBox(
                height: 8,
              ),
              Row(
                children: buildCoupon(),
              )
            ],
          ))
        ],
      ),
    );
  }

  buildCoupon() {
    List<Widget> listWidget = List();
    for (var index = 0; index < 3; index++) {
      listWidget.add(Container(
        decoration: BoxDecoration(color: HexColor.fromHex("#FFFEEFEF")),
        padding: EdgeInsets.only(left: 4, right: 4, bottom: 1, top: 1),
        child: Text(
          "50元",
          style: TextStyle(color: HexColor.fromHex("#FFFF4242"), fontSize: 11),
        ),
      ));
    }
    return listWidget;
  }
}
