myHTab static method

Tab myHTab(
  1. String title,
  2. bool isCurrent,
  3. BuildContext context, {
  4. double tabWidth = 0.0,
  5. double tabHeight = 0.0,
  6. EdgeInsets? padding,
  7. double fontSize = 12.0,
  8. double indicatorH = 8.0,
  9. double? indicatorW,
  10. int titlesLen = 0,
  11. Color indicatorColor = UIData.accentColor,
  12. Color normalColor = UIData.textGN,
  13. bool hasVDivider = false,
})

Implementation

static Tab myHTab(String title, bool isCurrent, BuildContext context,
    {double tabWidth = 0.0,
    double tabHeight = 0.0,
    EdgeInsets? padding,
    double fontSize = 12.0,
    double indicatorH = 8.0,
    double? indicatorW,
    int titlesLen = 0,
    Color indicatorColor = UIData.accentColor,
    Color normalColor = UIData.textGN,
    bool hasVDivider = false}) {
  if (titlesLen > 0) {
    double w = MxBaseUserInfo.instance.deviceSize.width;
    tabWidth = titlesLen == 0
        ? 55
        : w / titlesLen > 55.0
            ? w / titlesLen
            : 55.0 * titlesLen / 2;
  }
  return Tab(
      key: UniqueKey(),
      child: Container(
        padding: padding,
        width: tabWidth > 0 ? tabWidth : null,
        decoration: hasVDivider
            ? BoxDecoration(
                border: Border(
                    right: BorderSide(
                        color: UIData.lineBg, width: UIData.lineH)))
            : null,
        child: Stack(
          children: <Widget>[
            Center(
              child: SizedBox.fromSize(
                size: Size(tabWidth > 100 ? tabWidth - 40.0 : 60.0,
                    tabHeight > 12.0 ? tabHeight : 18.0),
                child: Center(
                  child: Text(
                    title,
                    maxLines: 2,
                    overflow: TextOverflow.ellipsis,
                    textAlign: TextAlign.center,
                    style: TextStyle(
                        fontSize: isCurrent ? fontSize + 1.0 : fontSize,
                        color: isCurrent ? indicatorColor : normalColor),
                  ),
                ),
              ),
            ),
            Column(
              children: <Widget>[
                Expanded(
                  child: SizedBox(
                    width: tabWidth > 0 ? tabWidth : 20,
                  ),
                ),
                Container(
                  margin: EdgeInsets.fromLTRB(5.0, 0.0, 5.0, 0.0),
                  height: indicatorH,
                  width: indicatorW,
                  child: MyAssetImageView(
                    '',
                    color: isCurrent ? indicatorColor : Colors.transparent,
                    width: indicatorW,
                    radius: indicatorH / 2,
                  ),
                ),
              ],
            )
          ],
        ),
      ));
}