import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:intl/intl.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:tab_indicator_styler/tab_indicator_styler.dart';
import 'package:zhiying_base_widget/dialog/select_date_ym_dialog/select_date_ym_dialog.dart';
import 'package:zhiying_base_widget/widgets/empty/empty_widget.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail_bloc.dart';
import 'package:zhiying_base_widget/widgets/wallet_bil_detail/wallet_bil_detail_widget_bloc.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/util/extension/color.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'model/wallet_style_model.dart';
import 'package:fluttertoast/fluttertoast.dart';

////钱包明细页面
class WalletBilDetail extends StatefulWidget {
  final Map<String, dynamic> data;

  const WalletBilDetail({Key key, this.data}) : super(key: key);

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

class _WalletBilDetailState extends State<WalletBilDetail>
    with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
  WalletBilDetailWidgetBloc _bloc;

  TabController _tabController;

  @override
  void initState() {
    _bloc = WalletBilDetailWidgetBloc();
    _bloc.initStyleData(json.decode(widget.data['data']));
    _tabController =
        TabController(length: _bloc.styleData.tabList.length, vsync: this);
    _bloc.loadInputData(_bloc.inPutCurrentPage, _bloc.inputShowDate);
    _bloc.loadOutputData(_bloc.outPutCurrentPage, _bloc.outputShowDate);

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return BlocProvider(
        bloc: _bloc,
        child: Container(
          child: Column(
            children: <Widget>[
              AppBar(
                brightness: Brightness.light,
                backgroundColor:
                    HexColor.fromHex(_bloc.styleData.appBarBgColor),
                centerTitle: true,
                leading: IconButton(
                    icon: Icon(
                      Icons.arrow_back_ios,
                      size: 18,
                      color: HexColor.fromHex(_bloc.styleData.appBarNameColor),
                    ),
                    onPressed: () {
                      Navigator.pop(context);
                    }),
                title: Text(
                  _bloc.styleData.appBarName ?? "",
                  style: TextStyle(
                      color: HexColor.fromHex(_bloc.styleData.appBarNameColor),
                      fontWeight: FontWeight.bold,
                      fontSize: 18),
                ),
              ),
              Container(
                color: Colors.white,
                child: TabBar(
                  indicator: MaterialIndicator(
                      height: 3,
                      horizontalPadding: 15,
                      bottomRightRadius: 1.5,
                      bottomLeftRadius: 1.5,
                      topRightRadius: 1.5,
                      topLeftRadius: 1.5,
                      color: HexColor.fromHex(_bloc.styleData.tabLineColor)),
                  controller: _tabController,
                  tabs: _buildTabBarItem(),
                  indicatorWeight: 9.5,
                  labelStyle:
                      TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
                  unselectedLabelStyle:
                      TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
                  labelColor: HexColor.fromHex(_bloc.styleData.tabSeletedColor),
                  unselectedLabelColor:
                      HexColor.fromHex(_bloc.styleData.tabNoSeletedColor),
                  indicatorColor:
                      HexColor.fromHex(_bloc.styleData.tabLineColor),
                  indicatorSize: TabBarIndicatorSize.label,
                ),
              ),
              Expanded(
                  child: TabBarView(
                      controller: _tabController,
                      children: _buildTabViewPage()))
            ],
          ),
        ));
  }

  ///创建tabbar按键
  _buildTabBarItem() {
    List<Widget> listWidget = List();
    for (var item in _bloc.styleData.tabList) {
      listWidget.add(Text(
        item.name ?? "",
      )
          // Tab(text: item.name ?? ""),
          );
    }
    return listWidget;
  }

  _buildType(List<InputTabViewBtns> tabViewBtns, TabList tabList) {
    var selectType;
    if (tabList.type == 'input') {
      selectType = _bloc.inputSelectType;
    } else {
      selectType = _bloc.outputSelectType;
    }
    return Row(
      children: <Widget>[
        SizedBox(width: 12.5),
        InkWell(
          onTap: () {
            ///显示日期选择弹窗
            _selectDate(tabList);
          },
          child: Padding(
              padding: const EdgeInsets.only(top: 8, bottom: 8),
              child: Text(
                  tabList.type == "input"
                      ? _bloc.inputShowDate
                      : _bloc.outputShowDate,
                  style: TextStyle(
                      fontSize: 14,
                      color: HexColor.fromHex(_bloc.styleData.timeSelectColor),
                      fontWeight: FontWeight.bold))),
        ),
        Icon(
          Icons.arrow_drop_down,
          color: HexColor.fromHex(_bloc.styleData.timeSelectColor),
        ),
        Expanded(
            child: Container(
          margin: const EdgeInsets.only(top: 15, bottom: 15, left: 12.5),
          height: 25,
          child: ListView.builder(
              scrollDirection: Axis.horizontal,
              shrinkWrap: true,
              itemCount: tabViewBtns.length,
              itemBuilder: (context, index) {
                return GestureDetector(
                  onTap: () async {
                    if (tabList.type == 'input') {
                      _bloc.inputSelectType = tabViewBtns[index].type;
                      _bloc.inPutCurrentPage = 1;
                      _bloc.loadInputData(
                          _bloc.inPutCurrentPage, _bloc.inputShowDate,
                          type: _bloc.inputSelectType);
                    } else {
                      _bloc.outputSelectType = tabViewBtns[index].type;
                      _bloc.outPutCurrentPage = 1;
                      _bloc.loadOutputData(
                          _bloc.outPutCurrentPage, _bloc.outputShowDate,
                          type: _bloc.outputSelectType);
                    }
                    _bloc.refresh();
                  },
                  behavior: HitTestBehavior.opaque,
                  child: Container(
                    alignment: Alignment.center,
                    margin: EdgeInsets.only(right: 12.5),
                    padding: EdgeInsets.only(
                        left: 16, right: 16, top: 2.5, bottom: 2.5),
                    decoration: BoxDecoration(
                        border: Border.all(
                          color: HexColor.fromHex(
                              selectType == tabViewBtns[index].type
                                  ? _bloc.styleData.btnSelectedColor
                                  : _bloc.styleData.btnNoSelectedColor),
                        ),
                        borderRadius: BorderRadius.circular(50)),
                    child: Text(
                      tabViewBtns[index].name ?? "",
                      style: TextStyle(
                          fontSize: 11,
                          color: HexColor.fromHex(
                              selectType == tabViewBtns[index].type
                                  ? _bloc.styleData.btnSelectedColor
                                  : _bloc.styleData.btnNoSelectedColor)),
                    ),
                  ),
                );
              }),
        ))
      ],
    );
  }

  _selectDate(TabList tabList) async {
    var result = await showDialog(
        context: context, builder: (context) => SelectDateYMDialog());
    if (result != null) {
      var dataTime = DateFormat('yyyy-MM').format(
          DateTime(int.parse(result['year']), int.parse(result['month'])));
      if (tabList.type == "input") {
        _bloc.inputShowDate = dataTime;
        _bloc.loadInputData(_bloc.inPutCurrentPage, _bloc.inputShowDate);
      } else {
        _bloc.outputShowDate = dataTime;
        _bloc.loadOutputData(_bloc.outPutCurrentPage, _bloc.outputShowDate);
      }
      _bloc.refresh();
    }
  }

  _buildBottomItem(TabList tabList) {
    return ListView.builder(
        shrinkWrap: true,
        itemCount: tabList.type == 'input'
            ? _bloc.inputDataVM.length
            : _bloc.outputDataVM.length,
        itemBuilder: (context, index) {
          return _buildItem(context, index, tabList);
        });
  }

  Widget _buildItem(BuildContext context, int index, TabList tabList) {
    if (tabList.type == 'input') {
      InputItemStyle inputItemStyle = _bloc.styleData.inputItemStyle;
      var modelItem = _bloc.inputDataVM[index];
      return Container(
        margin: EdgeInsets.only(left: 12.5, right: 12.5, bottom: 4, top: 4),
        padding: EdgeInsets.only(left: 12.5, right: 12.5, top: 10, bottom: 10),
        decoration: BoxDecoration(
            color: HexColor.fromHex("#FFFFFF"),
            borderRadius: BorderRadius.circular(8)),
        child: Column(
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Row(
                  children: <Widget>[
                    Container(
                      decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(4),
                          color: HexColor.fromHex("#FFFFF3F3"),
                          border: Border.all(
                              color: HexColor.fromHex(
                                  inputItemStyle.typeNameColor))),
                      child: Padding(
                        padding: const EdgeInsets.only(
                            left: 4, right: 4, top: 2, bottom: 2),
                        child: Center(
                          child: Text(
                            modelItem['type'] ?? "",
                            style: TextStyle(
                                color: HexColor.fromHex(
                                    inputItemStyle.typeNameColor),
                                fontSize: 10),
                          ),
                        ),
                      ),
                    ),
                    Container(
                        width: 176.5,
                        margin: EdgeInsets.only(left: 7.5),
                        child: Text(
                          modelItem['title'] ?? "",
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          style: TextStyle(fontSize: 14),
                        ))
                  ],
                ),
                Row(
                  children: <Widget>[
                    Text(
                      "+ ",
                      style: TextStyle(
                          color: HexColor.fromHex(inputItemStyle.amountColor)),
                    ),
                    Text(
                      "¥ " + modelItem['amount'],
                      style: TextStyle(
                          color: HexColor.fromHex(inputItemStyle.amountColor),
                          fontSize: 15,
                          fontFamily: 'Din',
                          package: 'zhiying_comm'),
                    )
                  ],
                )
              ],
            ),
            SizedBox(
              height: 4,
            ),

            ///订单编号
            Row(
              children: <Widget>[
                Text(
                  inputItemStyle.orderIdText,
                  style: TextStyle(
                      color: HexColor.fromHex(inputItemStyle.contentColor),
                      fontSize: 11),
                ),
                SizedBox(
                  width: 4,
                ),
                Text(
                  modelItem['order_id'],
                  style: TextStyle(
                      color: HexColor.fromHex(inputItemStyle.contentColor),
                      fontSize: 11),
                ),
                SizedBox(
                  width: 14,
                ),
                GestureDetector(
                  onTap: () {
                    Clipboard.setData(
                        ClipboardData(text: modelItem['order_id']));
                    Fluttertoast.showToast(msg: "已复制");
                  },
                  child: Container(
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(4),
                        color: HexColor.fromHex(inputItemStyle.copyBtnBgColor),
                        border: Border.all(
                            color:
                                HexColor.fromHex(inputItemStyle.contentColor),
                            width: 0.5)),
                    child: Padding(
                      padding: EdgeInsets.only(
                          left: 16, right: 16, top: 1, bottom: 1),
                      child: Text(
                        inputItemStyle.copyBtnText,
                        style: TextStyle(
                            color: HexColor.fromHex(
                                inputItemStyle.copyBtnTextColor),
                            fontSize: 11),
                      ),
                    ),
                  ),
                )
              ],
            ),
            SizedBox(
              height: 4,
            ),
            Row(
              children: <Widget>[
                Expanded(
                    child: Row(
                  children: <Widget>[
                    Text(
                      inputItemStyle.orderTypeText,
                      style: TextStyle(
                          color: HexColor.fromHex(inputItemStyle.contentColor),
                          fontSize: 11),
                    ),
                    SizedBox(
                      width: 4,
                    ),
                    Text(
                      modelItem['order_type'] ?? "",
                      style: TextStyle(
                          color: HexColor.fromHex("#FF999999"), fontSize: 11),
                    ),
                  ],
                )),
                Expanded(
                    child: Row(
                  children: <Widget>[
                    Text(
                      inputItemStyle.amountText + " ¥" + modelItem['amount'],
                      style: TextStyle(
                          color: HexColor.fromHex(inputItemStyle.contentColor),
                          fontSize: 11),
                    ),
                  ],
                ))
              ],
            ),
            SizedBox(
              height: 4,
            ),
            Row(
              children: <Widget>[
                Expanded(
                    child: Row(
                  children: <Widget>[
                    Text(
                      inputItemStyle.timeText,
                      style: TextStyle(
                          color: HexColor.fromHex(inputItemStyle.contentColor),
                          fontSize: 11),
                    ),
                    SizedBox(
                      width: 4,
                    ),
                    Text(
                      modelItem['time'] ?? "",
                      style: TextStyle(
                          color: HexColor.fromHex("#FF999999"), fontSize: 11),
                    ),
                  ],
                )),
                Expanded(
                    child: Row(
                  children: <Widget>[
                    Text(
                      inputItemStyle.settleTimeText +
                              " " +
                              modelItem['settle_time'] ??
                          "",
                      style: TextStyle(
                          color: HexColor.fromHex(inputItemStyle.contentColor),
                          fontSize: 11),
                    ),
                  ],
                ))
              ],
            ),
          ],
        ),
      );
    } else if (tabList.type == 'output') {
      OutputItemStyle outputItemStyle = _bloc.styleData.outputItemStyle;
      var modelItem = _bloc.outputDataVM[index];
      if (modelItem['type'] == '消费') {
        ///消费返回的Item
        return Container(
          margin: EdgeInsets.only(left: 12.5, right: 12.5, bottom: 4, top: 4),
          padding:
              EdgeInsets.only(left: 12.5, right: 12.5, top: 10, bottom: 10),
          decoration: BoxDecoration(
              color: HexColor.fromHex("#FFFFFF"),
              borderRadius: BorderRadius.circular(8)),
          child: Column(
            children: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Row(
                    children: <Widget>[
                      Container(
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(4),
                            color: HexColor.fromHex("#FFFFF3F3"),
                            border: Border.all(
                                color: HexColor.fromHex(
                                    outputItemStyle.typeNameColor))),
                        child: Padding(
                          padding: const EdgeInsets.only(
                              left: 4, right: 4, top: 2, bottom: 2),
                          child: Center(
                            child: Text(
                              modelItem['type'] ?? "",
                              style: TextStyle(
                                  color: HexColor.fromHex(
                                      outputItemStyle.typeNameColor),
                                  fontSize: 10),
                            ),
                          ),
                        ),
                      ),
                      Container(
                          width: 176.5,
                          margin: EdgeInsets.only(left: 7.5),
                          child: Text(
                            modelItem['title'] ?? "",
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(fontSize: 14),
                          ))
                    ],
                  ),
                  Row(
                    children: <Widget>[
                      Text(
                        "- ",
                        style: TextStyle(
                            color:
                                HexColor.fromHex(outputItemStyle.amountColor)),
                      ),
                      Text(
                        "¥ " + modelItem['amount'],
                        style: TextStyle(
                            color:
                                HexColor.fromHex(outputItemStyle.amountColor),
                            fontSize: 15),
                      )
                    ],
                  )
                ],
              ),
              SizedBox(
                height: 4,
              ),

              ///订单编号
              Row(
                children: <Widget>[
                  Text(
                    outputItemStyle.orderIdText,
                    style: TextStyle(
                        color: HexColor.fromHex(outputItemStyle.contentColor),
                        fontSize: 11),
                  ),
                  SizedBox(
                    width: 4,
                  ),
                  Text(
                    modelItem['order_id'],
                    style: TextStyle(
                        color: HexColor.fromHex(outputItemStyle.contentColor),
                        fontSize: 11),
                  ),
                  SizedBox(
                    width: 14,
                  ),
                  GestureDetector(
                    onTap: () {
                      Clipboard.setData(
                          ClipboardData(text: modelItem['order_id']));
                      Fluttertoast.showToast(msg: "已复制");
                    },
                    child: Container(
                      decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(4),
                          color:
                              HexColor.fromHex(outputItemStyle.copyBtnBgColor),
                          border: Border.all(
                              color: HexColor.fromHex(
                                  outputItemStyle.contentColor),
                              width: 0.5)),
                      child: Padding(
                        padding: EdgeInsets.only(
                            left: 16, right: 16, top: 1, bottom: 1),
                        child: Text(
                          outputItemStyle.copyBtnText ?? "",
                          style: TextStyle(
                              color: HexColor.fromHex(
                                  outputItemStyle.contentColor),
                              fontSize: 11),
                        ),
                      ),
                    ),
                  )
                ],
              ),
              SizedBox(
                height: 4,
              ),
              Row(
                children: <Widget>[
                  Expanded(
                      child: Row(
                    children: <Widget>[
                      Text(
                        outputItemStyle.consumeOrderTypeText,
                        style: TextStyle(
                            color:
                                HexColor.fromHex(outputItemStyle.contentColor),
                            fontSize: 11),
                      ),
                      SizedBox(
                        width: 4,
                      ),
                      Text(
                        modelItem['order_type'] ?? "",
                        style: TextStyle(
                            color: HexColor.fromHex("#FF999999"), fontSize: 11),
                      ),
                    ],
                  )),
                  Expanded(
                      child: Row(
                    children: <Widget>[
                      Text(
                        outputItemStyle.consumeAmountText +
                            " ¥" +
                            modelItem['amount'],
                        style: TextStyle(
                            color:
                                HexColor.fromHex(outputItemStyle.contentColor),
                            fontSize: 11),
                      ),
                    ],
                  ))
                ],
              ),
              SizedBox(
                height: 4,
              ),
              Row(
                children: <Widget>[
                  Expanded(
                      child: Row(
                    children: <Widget>[
                      Text(
                        outputItemStyle.consumeTimeText,
                        style: TextStyle(
                            color:
                                HexColor.fromHex(outputItemStyle.contentColor),
                            fontSize: 11),
                      ),
                      SizedBox(
                        width: 4,
                      ),
                      Text(
                        modelItem['time'] ?? "",
                        style: TextStyle(
                            color: HexColor.fromHex("#FF999999"), fontSize: 11),
                      ),
                    ],
                  )),
                  // Expanded(
                  //     child: Row(
                  //       children: <Widget>[
                  //         Text(
                  //           inputItemStyle.consumeTimeText +
                  //               " " +
                  //               modelItem['settle_time'] ??
                  //               "",
                  //           style: TextStyle(
                  //               color: HexColor.fromHex(inputItemStyle.contentColor),
                  //               fontSize: 22.sp),
                  //         ),
                  //       ],
                  //     ))
                ],
              ),
            ],
          ),
        );
      } else if (modelItem['type'] == '提现') {
        return Container(
          margin: EdgeInsets.only(left: 12.5, right: 12.5, bottom: 4, top: 4),
          padding:
              EdgeInsets.only(left: 12.5, right: 12.5, top: 10, bottom: 10),
          decoration: BoxDecoration(
              color: HexColor.fromHex("#FFFFFF"),
              borderRadius: BorderRadius.circular(8)),
          child: Column(
            children: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Row(
                    children: <Widget>[
                      Container(
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(4),
                            color: HexColor.fromHex("#FFFFF3F3"),
                            border: Border.all(
                                color: HexColor.fromHex(
                                    outputItemStyle.typeNameColor))),
                        child: Padding(
                          padding: const EdgeInsets.only(
                              left: 4, right: 4, top: 2, bottom: 2),
                          child: Center(
                            child: Text(
                              modelItem['type'] ?? "",
                              style: TextStyle(
                                  color: HexColor.fromHex(
                                      outputItemStyle.typeNameColor),
                                  fontSize: 10),
                            ),
                          ),
                        ),
                      ),
                      Container(
                          width: 176.5,
                          margin: EdgeInsets.only(left: 12.5),
                          child: Text(
                            modelItem['title'] ?? "",
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(fontSize: 14),
                          ))
                    ],
                  ),
                  Row(
                    children: <Widget>[
                      Text(
                        "- ",
                        style: TextStyle(
                            color:
                                HexColor.fromHex(outputItemStyle.amountColor)),
                      ),
                      Text(
                        "¥ " + modelItem['amount'],
                        style: TextStyle(
                            color:
                                HexColor.fromHex(outputItemStyle.amountColor),
                            fontSize: 15),
                      )
                    ],
                  )
                ],
              ),
              SizedBox(
                height: 4,
              ),

              ///订单编号
              Row(
                children: <Widget>[
                  Text(
                    outputItemStyle.orderIdText,
                    style: TextStyle(
                        color: HexColor.fromHex(outputItemStyle.contentColor),
                        fontSize: 11),
                  ),
                  SizedBox(
                    width: 4,
                  ),
                  Text(
                    modelItem['order_id'],
                    style: TextStyle(
                        color: HexColor.fromHex(outputItemStyle.contentColor),
                        fontSize: 11),
                  ),
                  SizedBox(
                    width: 14,
                  ),
                  GestureDetector(
                    onTap: () {
                      Clipboard.setData(
                          ClipboardData(text: modelItem['order_id']));
                      Fluttertoast.showToast(msg: "已复制");
                    },
                    child: Container(
                      decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(4),
                          color:
                              HexColor.fromHex(outputItemStyle.copyBtnBgColor),
                          border: Border.all(
                              color: HexColor.fromHex(
                                  outputItemStyle.contentColor),
                              width: 0.5)),
                      child: Padding(
                        padding: EdgeInsets.only(
                            left: 16, right: 16, top: 1, bottom: 1),
                        child: Text(
                          outputItemStyle.copyBtnText ?? "",
                          style: TextStyle(
                              color: HexColor.fromHex(
                                  outputItemStyle.contentColor),
                              fontSize: 11),
                        ),
                      ),
                    ),
                  )
                ],
              ),
              SizedBox(
                height: 4,
              ),
              Row(
                children: <Widget>[
                  Expanded(
                      child: Row(
                    children: <Widget>[
                      Text(
                        outputItemStyle.withdrawAccountText,
                        style: TextStyle(
                            color:
                                HexColor.fromHex(outputItemStyle.contentColor),
                            fontSize: 11),
                      ),
                      SizedBox(
                        width: 4,
                      ),
                      Text(
                        modelItem['account'] ?? "",
                        style: TextStyle(
                            color:
                                HexColor.fromHex(outputItemStyle.contentColor),
                            fontSize: 11),
                      ),
                    ],
                  )),
                  Expanded(
                      child: Row(
                    children: <Widget>[
                      Text(
                        outputItemStyle.withdrawAmountText +
                            " ¥" +
                            modelItem['amount'],
                        style: TextStyle(
                            color:
                                HexColor.fromHex(outputItemStyle.contentColor),
                            fontSize: 11),
                      ),
                    ],
                  ))
                ],
              ),
              SizedBox(height: 4),
              Row(
                children: <Widget>[
                  Expanded(
                      child: Row(
                    children: <Widget>[
                      Text(
                        outputItemStyle.withdrawTimeText,
                        style: TextStyle(
                            color:
                                HexColor.fromHex(outputItemStyle.contentColor),
                            fontSize: 11),
                      ),
                      SizedBox(
                        width: 4,
                      ),
                      Text(
                        modelItem['time'] ?? "",
                        style: TextStyle(
                            color: HexColor.fromHex("#FF999999"), fontSize: 11),
                      ),
                    ],
                  )),
                  Expanded(
                      child: Row(
                    children: <Widget>[
                      Text(
                        outputItemStyle.withdrawOrderStatusText +
                                " " +
                                modelItem['order_status'] ??
                            "",
                        style: TextStyle(
                            color:
                                HexColor.fromHex(outputItemStyle.contentColor),
                            fontSize: 11),
                      ),
                    ],
                  ))
                ],
              ),
            ],
          ),
        );
      }
    }
  }

  _buildTabViewPage() {
    List<Widget> listWidget = List();
    for (var item in _bloc.styleData.tabList) {
      List<InputTabViewBtns> tabViewBtns;

      if (item.type == 'input') {
        tabViewBtns = _bloc.styleData.inputTabViewBtns;
        listWidget.add(StreamBuilder(
            stream: _bloc.inputOutData,
            builder: (context, asny) {
              // dataVM = asny.data;
              return Container(
                child: Column(
                  children: <Widget>[
                    _buildType(tabViewBtns, item),
                    Expanded(
                      child: SmartRefresher(
                          controller: _bloc.inputRefreshController,
                          enablePullDown: true,
                          enablePullUp: true,
                          onLoading: () {
                            _bloc.inputLoad();
                          },
                          onRefresh: () {
                            _bloc.inputRefresh();
                          },
                          child: EmptyUtil.isEmpty(_bloc.inputDataVM)
                              ? EmptyWidget()
                              : _buildBottomItem(item)),
                    )
                  ],
                ),
              );
            }));
      } else {
        tabViewBtns = _bloc.styleData.outTabViewBtns;
        listWidget.add(StreamBuilder(
            stream: _bloc.outputOutData,
            builder: (context, asny) {
              // dataVM = asny.data;

              return Container(
                child: Column(
                  children: <Widget>[
                    _buildType(tabViewBtns, item),
                    Expanded(
                      child: SmartRefresher(
                          controller: _bloc.outputRefreshController,
                          enablePullDown: true,
                          enablePullUp: true,
                          onLoading: () {
                            _bloc.outputLoad();
                          },
                          onRefresh: () {
                            _bloc.outputRefresh();
                          },
                          child: EmptyUtil.isEmpty(_bloc.outputDataVM)
                              ? EmptyWidget()
                              : _buildBottomItem(item)),
                    )
                  ],
                ),
              );
            }));
      }
    }
    return listWidget;
  }

  @override
  // TODO: implement wantKeepAlive
  bool get wantKeepAlive => true;
}
