myVTab static method

Tab myVTab(
  1. String title,
  2. bool isCurrent,
  3. BuildContext context, {
  4. Color indicatorColor = UIData.primaryColor,
  5. Color titleNColor = UIData.black,
  6. num indicatorH = 100,
  7. num indicatorW = 8,
  8. Color unselectedTabBackgroundColor = UIData.pureWhite,
  9. Color selectedTabBackgroundColor = UIData.pureWhite,
  10. MyVerticalTwoDimensionBean? data,
  11. Function? selectPage,
})

Implementation

static Tab myVTab(
  String title,
  bool isCurrent,
  BuildContext context, {
  Color indicatorColor = UIData.primaryColor,
  Color titleNColor = UIData.black,
  num indicatorH = 100,
  num indicatorW = 8,
  Color unselectedTabBackgroundColor = UIData.pureWhite,
  Color selectedTabBackgroundColor = UIData.pureWhite,
  MyVerticalTwoDimensionBean? data,
  Function? selectPage,
}) {
  var isZhg = true;

  var textWidget = Text(
    title,
    maxLines: 2,
    overflow: TextOverflow.ellipsis,
    style: TextStyle(
        fontSize: 12.0,
        color: isZhg
            ? UIData.pureWhite
            : isCurrent
                ? indicatorColor
                : titleNColor),
  ).box.padding(EdgeInsets.only(left: 5.0, right: 5.0)).make();

  return Tab(
    child: VStack([
      Stack(
        children: [
          Row(
            children: [
              Expanded(
                  child: MyAssetImageView(
                'ic_shop_cate_zhg_bg.png',
                width: 86.hsp,
                fit: BoxFit.fill,
              )
                      .box
                      .color(Colors.transparent)
                      .padding(EdgeInsets.fromLTRB(2.0, .0, 2.0, 0.0))
                      .make())
            ],
          ),
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              isZhg
                  ? SizedBox()
                  : Container(
                      margin: EdgeInsets.fromLTRB(0.0, 0.0, 8.0, 0.0),
                      decoration: isCurrent
                          ? BoxDecoration(color: indicatorColor)
                          : null,
                      width: indicatorW.toDouble(),
                      height: indicatorH.toDouble(),
                    ),
              Expanded(
                  child: Container(
                padding: EdgeInsets.only(bottom: 8.0),
                child: isZhg ? textWidget.centered() : textWidget,
              )),
            ],
          ),
        ],
        alignment: AlignmentDirectional.center,
      ).box.height(48.vsp).make(),
      isCurrent
          ? MyStillListView(data!.children, (context, index) {
              var item = data.children![index];
              return Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                  isZhg && !item.current
                      ? Container(
                          margin: EdgeInsets.fromLTRB(0.0, 0.0, 5.0, 0.0),
                          decoration: null,
                          width: indicatorW.toDouble(),
                          height: indicatorH.toDouble(),
                        )
                      : Container(
                          margin: EdgeInsets.fromLTRB(0.0, 0.0, 5.0, 0.0),
                          decoration: isCurrent
                              ? BoxDecoration(color: indicatorColor)
                              : null,
                          width: indicatorW.toDouble(),
                          height: indicatorH.toDouble(),
                        ),
                  Expanded(
                    child: Container(
                        child: Text(
                      item.title!,
                      maxLines: 2,
                      overflow: TextOverflow.ellipsis,
                      style: TextStyle(
                          fontSize: 12.0,
                          color: isZhg
                              ? UIData.black
                              : isCurrent
                                  ? indicatorColor
                                  : titleNColor),
                    ).centered()),
                  ),
                ],
              )
                  .box
                  .color(item.current
                      ? selectedTabBackgroundColor
                      : unselectedTabBackgroundColor)
                  .height(48.vsp)
                  .make()
                  .xOnTap(() {
                if (selectPage != null) selectPage(item.idx);
              });
            })
          : SizedBox(),
    ])
        .box
        .height(isZhg && isCurrent
            ? 48.vsp * (data!.children!.length + 1)
            : 48.vsp)
        .make(),
  );
}