Skip to content

Commit bbafb0d

Browse files
committed
feat(tab): add persistentTabBar option for keep the tab pinned
1 parent 7b3b3ed commit bbafb0d

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

modules/ensemble/lib/layout/tab/tab_bar_controller.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class TabBarController extends BoxController {
3131

3232
int selectedIndex = 0;
3333

34+
bool persistentTabBar = false;
35+
3436
List<TabItem> _originalItems = [];
3537
List<TabItem> _visibleItems = [];
3638

modules/ensemble/lib/layout/tab_bar.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ abstract class BaseTabBar extends StatefulWidget
9090
EnsembleAction.from(action, initiator: this),
9191
'onTabSelectionHaptic': (value) =>
9292
_controller.onTabSelectionHaptic = Utils.optionalString(value),
93+
'persistentTabBar': (value) =>
94+
_controller.persistentTabBar = Utils.getBool(value, fallback: false),
9395
};
9496
}
9597
}
@@ -282,7 +284,12 @@ class TabBarState extends BaseTabBarState {
282284
// builder gives us dynamic height control vs TabBarView, but
283285
// is sub-optimal since it recreates the tab content on each pass.
284286
// This means onLoad API may be called multiple times in debug mode
285-
tabContent
287+
288+
widget._controller.persistentTabBar
289+
? Expanded(
290+
child: SingleChildScrollView(
291+
child: tabContent))
292+
: tabContent,
286293

287294
// This cause Expanded child to fail
288295
// Padding(
@@ -320,4 +327,4 @@ class TabBarState extends BaseTabBarState {
320327
}
321328
return const Text("Unknown widget for this Tab");
322329
}
323-
}
330+
}

0 commit comments

Comments
 (0)