tabTile method
Widget
tabTile({
- required TabItem tabItem,
- required BuildContext context,
- required int index,
- required ValueNotifier<
int> itemChildSelected, - bool isLevelOne = false,
Implementation
Widget tabTile({
required TabItem tabItem,
required BuildContext context,
required int index,
required ValueNotifier<int> itemChildSelected,
bool isLevelOne = false,
}) {
bool isETSelected = isExpansionTileSelected;
ValueNotifier<int> icSelected = ValueNotifier<int>(-1);
debugPrint("tabItem: ${tabItem.badgeCount}");
return ListTileTheme(
selectedColor: widget.selectedColor ?? Theme.of(context).primaryColor,
child: tabItem.children!.isEmpty
? Container(
margin: isLevelOne == true
? null
: EdgeInsets.only(left: widget.childIndentation),
child: ListTile(
onTap: () {
tabItem.onTap!();
setState(() {
itemChildSelected.value = index;
widget.onChange(itemChildSelected.value);
});
},
leading: tabItem.selectedLeadingIcon,
trailing: tabItem.badgeCount != 0
? SizedBox(
width: 50,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
margin: const EdgeInsets.only(right: 5),
width: 22,
child: ListView(
reverse: true,
scrollDirection: Axis.horizontal,
children: [tabItem.trailingIcon ?? Container()],
),
),
Expanded(
child: BadgeContainer(
count: tabItem.badgeCount ?? 0)),
],
),
)
: tabItem.trailingIcon,
title: tabItem.title,
subtitle: tabItem.subTitle,
selected: itemChildSelected.value == index,
dense: true,
iconColor: widget.unSelectedColor ?? Colors.black,
textColor: widget.unSelectedColor ?? Colors.black,
),
)
: Container(
margin: isLevelOne == true
? null
: EdgeInsets.only(left: widget.childIndentation),
child: ListTileTheme(
selectedColor:
widget.selectedColor ?? Theme.of(context).primaryColor,
child: ExpansionTile(
onExpansionChanged: (isSelected) {
setState(() {
isETSelected = isSelected;
isExpansionTileSelected = isSelected;
itemChildSelected.value = index;
icSelected.value = index;
widget.onChange(icSelected.value);
});
},
iconColor:
widget.selectedColor ?? Theme.of(context).primaryColor,
textColor:
widget.selectedColor ?? Theme.of(context).primaryColor,
collapsedIconColor: icSelected.value == index
? widget.selectedColor ?? Theme.of(context).primaryColor
: Colors.black,
collapsedTextColor: icSelected.value == index
? widget.selectedColor ?? Theme.of(context).primaryColor
: Colors.black,
title: tabItem.title,
maintainState: true,
initiallyExpanded: isETSelected ? true : false,
subtitle: tabItem.subTitle,
leading: tabItem.selectedLeadingIcon,
trailing: tabItem.trailingIcon != null
? SizedBox(
width: widget.expandedWidth * 0.2,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
tabItem.trailingIcon ?? Container(),
Expanded(
child: isETSelected
? widget.selectedTrailingIcon!
: widget.unSelectedTrailingIcon!),
tabItem.badgeCount != 0
? Container(
margin: const EdgeInsets.only(left: 1),
child: Expanded(
child: BadgeContainer(
count: tabItem.badgeCount ?? 0,
notifiAsDot: true)))
: Container(),
],
),
)
: isETSelected
? (tabItem.badgeCount != 0
? SizedBox(
width: 30,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
widget.selectedTrailingIcon ??
Container(),
Expanded(
child: BadgeContainer(
count: tabItem.badgeCount ?? 0,
notifiAsDot: true)),
],
),
)
: widget.selectedTrailingIcon!)
: (tabItem.badgeCount != 0
? SizedBox(
width: 30,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
widget.unSelectedTrailingIcon ??
Container(),
Expanded(
child: BadgeContainer(
count: tabItem.badgeCount ?? 0,
notifiAsDot: true)),
],
),
)
: widget.unSelectedTrailingIcon!),
children: tabExpansionTile(
tabItem: tabItem,
context: context,
itemChildSelected: icSelected,
),
),
),
),
);
}