opt: hide home button when it only exists on tab
This commit is contained in:
parent
f1bfb12494
commit
d939fdac72
@ -490,6 +490,15 @@ class _ListView extends StatelessWidget {
|
|||||||
this.tabBuilder,
|
this.tabBuilder,
|
||||||
this.labelGetter});
|
this.labelGetter});
|
||||||
|
|
||||||
|
/// Check whether to show ListView
|
||||||
|
///
|
||||||
|
/// Conditions:
|
||||||
|
/// - hide single item when only has one item (home) on [DesktopTabPage].
|
||||||
|
bool isHideSingleItem() {
|
||||||
|
return state.value.tabs.length == 1 &&
|
||||||
|
controller.tabType == DesktopTabType.main;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Obx(() => ListView(
|
return Obx(() => ListView(
|
||||||
@ -497,38 +506,41 @@ class _ListView extends StatelessWidget {
|
|||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const BouncingScrollPhysics(),
|
physics: const BouncingScrollPhysics(),
|
||||||
children: state.value.tabs.asMap().entries.map((e) {
|
children: isHideSingleItem()
|
||||||
final index = e.key;
|
? List.empty()
|
||||||
final tab = e.value;
|
: state.value.tabs.asMap().entries.map((e) {
|
||||||
return _Tab(
|
final index = e.key;
|
||||||
index: index,
|
final tab = e.value;
|
||||||
label: labelGetter == null
|
return _Tab(
|
||||||
? Rx<String>(tab.label)
|
index: index,
|
||||||
: labelGetter!(tab.label),
|
label: labelGetter == null
|
||||||
selectedIcon: tab.selectedIcon,
|
? Rx<String>(tab.label)
|
||||||
unselectedIcon: tab.unselectedIcon,
|
: labelGetter!(tab.label),
|
||||||
closable: tab.closable,
|
selectedIcon: tab.selectedIcon,
|
||||||
selected: state.value.selected,
|
unselectedIcon: tab.unselectedIcon,
|
||||||
onClose: () {
|
closable: tab.closable,
|
||||||
if (tab.onTabCloseButton != null) {
|
selected: state.value.selected,
|
||||||
tab.onTabCloseButton!();
|
onClose: () {
|
||||||
} else {
|
if (tab.onTabCloseButton != null) {
|
||||||
controller.remove(index);
|
tab.onTabCloseButton!();
|
||||||
}
|
} else {
|
||||||
},
|
controller.remove(index);
|
||||||
onSelected: () => controller.jumpTo(index),
|
}
|
||||||
tabBuilder: tabBuilder == null
|
|
||||||
? null
|
|
||||||
: (Widget icon, Widget labelWidget, TabThemeConf themeConf) {
|
|
||||||
return tabBuilder!(
|
|
||||||
tab.label,
|
|
||||||
icon,
|
|
||||||
labelWidget,
|
|
||||||
themeConf,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
onSelected: () => controller.jumpTo(index),
|
||||||
}).toList()));
|
tabBuilder: tabBuilder == null
|
||||||
|
? null
|
||||||
|
: (Widget icon, Widget labelWidget,
|
||||||
|
TabThemeConf themeConf) {
|
||||||
|
return tabBuilder!(
|
||||||
|
tab.label,
|
||||||
|
icon,
|
||||||
|
labelWidget,
|
||||||
|
themeConf,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}).toList()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user