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 = 14.0,
  8. double indicatorH = 8.0,
  9. double topPadding = 15.0,
  10. double? indicatorW,
  11. double barWidth = 0.0,
  12. int titlesLen = 0,
  13. Color indicatorColor = UIData.accentColor,
  14. Color? titleColor,
  15. double? h,
  16. Color normalColor = UIData.textGN,
  17. Color highLightColor = UIData.accentColor,
  18. String? indicatorIcon,
  19. 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 = 14.0,
    double indicatorH = 8.0,
    double topPadding = 15.0,
    double? indicatorW,
    double barWidth = 0.0,
    int titlesLen = 0,
    Color indicatorColor = UIData.accentColor,
    Color? titleColor,
    double? h,
    Color normalColor = UIData.textGN,
    Color highLightColor = UIData.accentColor,
    String? indicatorIcon,
    bool hasVDivider = false}) {
  double fSize = isCurrent ? fontSize + 1 : fontSize;
  double w =
      barWidth > 1 ? barWidth : MxBaseUserInfo.instance.deviceSize.width;
  tabWidth = titlesLen != 0
      ? w / titlesLen > 85
          ? w / titlesLen
          : '$title'.textWidth(style: TextStyle(fontSize: fSize))
      : '$title'.textWidth(style: TextStyle(fontSize: fSize));

  return Tab(
      key: UniqueKey(),
      height: h,
      iconMargin: EdgeInsets.zero,
      child: Container(
        padding: padding,
        width: tabWidth > 100
            ? tabWidth - 40.0
            : '${title}'.length * 25.toDouble(),
        decoration: hasVDivider
            ? BoxDecoration(
                border: Border(
                    right: BorderSide(
                        color: UIData.lineBg, width: UIData.lineH)))
            : null,
        child: Column(
          children: <Widget>[
            SizedBox.fromSize(
              size: Size(
                  tabWidth > 100
                      ? tabWidth
                      : '${title}'.length * 35.toDouble(),
                  tabHeight > 12.0 ? tabHeight : 30.vsp),
              child: Center(
                child: Text(
                  title,
                  maxLines: 2,
                  overflow: TextOverflow.ellipsis,
                  textAlign: TextAlign.center,
                  style: TextStyle(
                      fontSize: fSize,
                      fontWeight:
                          isCurrent ? FontWeight.w500 : FontWeight.normal,
                      color: titleColor != null
                          ? titleColor
                          : isCurrent
                              ? highLightColor
                              : normalColor),
                ),
              ),
            ),
            Container(
              margin: EdgeInsets.fromLTRB(5.0, 5.0, 5.0, 0.0),
              height: indicatorH,
              width: indicatorW,
              child: indicatorIcon.textEmpty()
                  ? MyAssetImageView(
                      '',
                      color: isCurrent ? indicatorColor : Colors.transparent,
                      width: indicatorW,
                      radius: indicatorH / 2,
                    )
                  : isCurrent
                      ? MyAssetImageView(
                          '$indicatorIcon',
                          width: indicatorW,
                          height: indicatorH,
                          fit: BoxFit.fill,
                        )
                      : SizedBox(),
            ),
          ],
          mainAxisAlignment: MainAxisAlignment.end,
        ),
      ));
}