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,7 +506,9 @@ 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()
|
||||||
|
? List.empty()
|
||||||
|
: state.value.tabs.asMap().entries.map((e) {
|
||||||
final index = e.key;
|
final index = e.key;
|
||||||
final tab = e.value;
|
final tab = e.value;
|
||||||
return _Tab(
|
return _Tab(
|
||||||
@ -519,7 +530,8 @@ class _ListView extends StatelessWidget {
|
|||||||
onSelected: () => controller.jumpTo(index),
|
onSelected: () => controller.jumpTo(index),
|
||||||
tabBuilder: tabBuilder == null
|
tabBuilder: tabBuilder == null
|
||||||
? null
|
? null
|
||||||
: (Widget icon, Widget labelWidget, TabThemeConf themeConf) {
|
: (Widget icon, Widget labelWidget,
|
||||||
|
TabThemeConf themeConf) {
|
||||||
return tabBuilder!(
|
return tabBuilder!(
|
||||||
tab.label,
|
tab.label,
|
||||||
icon,
|
icon,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user