opt: hide home button when it only exists on tab

This commit is contained in:
Kingtous 2022-09-23 11:01:33 +08:00
parent f1bfb12494
commit d939fdac72

View File

@ -490,6 +490,15 @@ class _ListView extends StatelessWidget {
this.tabBuilder,
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
Widget build(BuildContext context) {
return Obx(() => ListView(
@ -497,7 +506,9 @@ class _ListView extends StatelessWidget {
scrollDirection: Axis.horizontal,
shrinkWrap: true,
physics: const BouncingScrollPhysics(),
children: state.value.tabs.asMap().entries.map((e) {
children: isHideSingleItem()
? List.empty()
: state.value.tabs.asMap().entries.map((e) {
final index = e.key;
final tab = e.value;
return _Tab(
@ -519,7 +530,8 @@ class _ListView extends StatelessWidget {
onSelected: () => controller.jumpTo(index),
tabBuilder: tabBuilder == null
? null
: (Widget icon, Widget labelWidget, TabThemeConf themeConf) {
: (Widget icon, Widget labelWidget,
TabThemeConf themeConf) {
return tabBuilder!(
tab.label,
icon,