library-ui: add floating action slot to the pager scaffold
- Commit
3600e69e8fda1d5f1ddd319cd65cfe4f5f5a5470- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-06 03:38 UTC (6 hours ago)
- Parents
c75f7e8
TabbedPagerScaffold's pager overload owned its host Scaffold but offered no floating-action slot, so a PrimaryTabRow screen whose primary action follows the selected page (health recipes and ingredients) could not adopt the shared pager without demoting its FAB to a toolbar button or wrapping the pager in a second scaffold. Forward a new floatingActionButton parameter (default empty, so every existing call site renders as before) to the host Scaffold in all three branches of the pager overload: expanded BottomNav, compact BottomNav, and PrimaryTabRow. The route-backed overload is unchanged; it has no FAB use case today. Verified: :library:ui:lint, :library:ui:lintVitalRelease and :library:ui:testDevUnitTest all pass.
Diff
library/ui/src/main/java/com/vayunmathur/library/ui/TabbedPagerScaffold.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/TabbedPagerScaffold.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/TabbedPagerScaffold.ktindex ecaae5959d..18f9ba5456 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/TabbedPagerScaffold.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/TabbedPagerScaffold.kt@@ -64,6 +64,8 @@ enum class TabStyle { * * [leadingBottomBar] sits above the tab bar in [TabStyle.BottomNav] (music's * now-playing controls) and is the plain bottom bar in [TabStyle.PrimaryTabRow].+ * [floatingActionButton] is forwarded to the host scaffold in every style, for+ * pages whose primary action follows the selected page (health recipes). * * In [TabStyle.BottomNav] the tab bar itself is width-aware: on expanded * windows ([WindowWidthClass.Expanded] — large tablets, ChromeOS, desktop)@@ -88,6 +90,7 @@ fun TabbedPagerScaffold( tabStyle: TabStyle = TabStyle.BottomNav, topBar: @Composable () -> Unit = {}, leadingBottomBar: @Composable () -> Unit = {},+ floatingActionButton: @Composable () -> Unit = {}, ) { val scope = rememberCoroutineScope() val select: (Int) -> Unit = { index ->@@ -101,6 +104,7 @@ fun TabbedPagerScaffold( modifier = modifier, topBar = topBar, bottomBar = leadingBottomBar,+ floatingActionButton = floatingActionButton, ) { padding -> // Do not forward the top padding: inner pages own their top // bar and consume the status-bar inset themselves, so@@ -142,6 +146,7 @@ fun TabbedPagerScaffold( Scaffold( modifier = modifier, topBar = topBar,+ floatingActionButton = floatingActionButton, bottomBar = { Column(Modifier.fillMaxWidth()) { leadingBottomBar()@@ -177,6 +182,7 @@ fun TabbedPagerScaffold( TabStyle.PrimaryTabRow -> Scaffold( modifier = modifier,+ floatingActionButton = floatingActionButton, topBar = { Column(Modifier.fillMaxWidth()) { topBar()