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