myHTab static method
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,
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,
),
));
}