NutrientTabBar

fun NutrientTabBar(documentCoordinator: DocumentCoordinator, modifier: Modifier = Modifier, closeMode: PdfTabBarCloseMode = PdfTabBarCloseMode.CLOSE_ONLY_SELECTED_TAB, colors: TabBarColors = UiTheme.colors.tabBar, dimensions: NutrientTabBarDimensions = NutrientTabBarDefaults.dimensions(), tabShape: Shape = NutrientTabBarDefaults.TabShape, tabSpacing: Dp = NutrientTabBarDefaults.TabSpacing, contentPadding: PaddingValues = NutrientTabBarDefaults.ContentPadding, windowInsets: WindowInsets = NutrientTabBarDefaults.windowInsets, listState: LazyListState = rememberLazyListState(), tabContent: @Composable NutrientTabBarTabScope.() -> Unit = { NutrientTabBarDefaults.TabContent(this) })

A tab bar for the documents of a DocumentCoordinator, one tab per document.

The bar mirrors the coordinator: documents become tabs, the visible document is the selected tab, and tapping, closing or dragging a tab is forwarded back to the coordinator. Use it with a com.pspdfkit.jetpack.compose.views.DocumentView by collecting com.pspdfkit.jetpack.compose.interactors.DocumentState.documentCoordinator, and hide the SDK's own tab bar with com.pspdfkit.configuration.activity.TabBarHidingMode.HIDE:

val coordinator by documentState.documentCoordinator.collectAsState()
Box {
DocumentView(documentState, Modifier.fillMaxSize())
coordinator?.let {
NutrientTabBar(documentCoordinator = it, tabShape = RoundedCornerShape(28.dp), tabSpacing = 8.dp)
}
}

A tap or a close updates the tabs at once so the bar can animate; the coordinator call that swaps the document follows NutrientTabBarDefaults.AnimationDurationMillis later, because replacing the document blocks the main thread long enough to freeze a running tab animation.

Parameters

documentCoordinator

The coordinator whose documents the bar shows.

modifier

The Modifier for the bar.

closeMode

Which tabs show a close button.

colors

The bar's colors, UiColorScheme.tabBar by default.

dimensions

The bar's dimensions, see NutrientTabBarDefaults.dimensions.

tabShape

Shape every tab is clipped to.

tabSpacing

Gap between neighbouring tabs. A non-zero gap replaces the separator between touching tabs.

contentPadding

Padding around the row of tabs, inside the bar's background.

windowInsets

Window insets the bar's background extends into while its tabs stay clear of them, see NutrientTabBarDefaults.windowInsets.

listState

State of the scrolling row, for callers that want to scroll it themselves.

tabContent

What to draw inside every tab, NutrientTabBarDefaults.TabContent by default.


fun NutrientTabBar(tabs: List<NutrientTabBarTab>, selectedTabId: Long?, onTabClick: (NutrientTabBarTab) -> Unit, onCloseClick: (NutrientTabBarTab) -> Unit, modifier: Modifier = Modifier, closeMode: PdfTabBarCloseMode = PdfTabBarCloseMode.CLOSE_ONLY_SELECTED_TAB, colors: TabBarColors = UiTheme.colors.tabBar, dimensions: NutrientTabBarDimensions = NutrientTabBarDefaults.dimensions(), tabShape: Shape = NutrientTabBarDefaults.TabShape, tabSpacing: Dp = NutrientTabBarDefaults.TabSpacing, contentPadding: PaddingValues = NutrientTabBarDefaults.ContentPadding, windowInsets: WindowInsets = NutrientTabBarDefaults.windowInsets, onTabMove: (fromIndex: Int, toIndex: Int) -> Boolean? = null, listState: LazyListState = rememberLazyListState(), tabContent: @Composable NutrientTabBarTabScope.() -> Unit = { NutrientTabBarDefaults.TabContent(this) })

A horizontal row of tabs driven by the caller's own state.

The tabs share the available width equally and never get narrower than NutrientTabBarDimensions.tabMinWidth plus the close button; once they no longer fit, the row scrolls. The selected tab is filled with TabBarColors.selectedTabColor. Touching tabs (a zero tabSpacing) show a thin separator in the same color at their end edge; spaced tabs don't.

A long press picks a tab up for reordering when onTabMove is set. It is called live for every position change during the drag and returns whether the caller applied the move, the contract ItemTouchHelper.Callback.onMove had.

Parameters

tabs

Tabs in display order. Each NutrientTabBarTab.id must be unique.

selectedTabId

Id of the selected tab, or null for none. It is scrolled into view whenever it changes.

onTabClick

Called when an unselected tab is tapped.

onCloseClick

Called when a tab's close button is tapped, or its content calls NutrientTabBarTabScope.closeTab.

modifier

The Modifier for the bar.

closeMode

Which tabs show a close button.

colors

The bar's colors, UiColorScheme.tabBar by default.

dimensions

The bar's dimensions, see NutrientTabBarDefaults.dimensions.

tabShape

Shape every tab is clipped to.

tabSpacing

Gap between neighbouring tabs.

contentPadding

Padding around the row of tabs, inside the bar's background.

windowInsets

Window insets the bar's background extends into while its tabs stay clear of them, see NutrientTabBarDefaults.windowInsets.

onTabMove

Applies a live reorder from one index to another; null disables drag-reorder.

listState

State of the scrolling row, for callers that want to scroll it themselves.

tabContent

What to draw inside every tab, NutrientTabBarDefaults.TabContent by default.