Repository navigation
Replies: 1 comment
|
For a fixed set of pages, model each page as a Voyager val pages = remember { listOf(HomeTab, ProfileTab) }
val pager = rememberPagerState(pageCount = { pages.size })
TabNavigator(
tab = pages.first(),
tabDisposable = { TabDisposable(it, pages) },
) { tabs ->
LaunchedEffect(pager, tabs) {
snapshotFlow { pager.settledPage }.collect { index ->
tabs.current = pages[index]
}
}
HorizontalPager(
state = pager,
key = { pages[it].key },
) { index ->
val tab = pages[index]
tabs.saveableState("pager-page", tab = tab) {
tab.Content()
}
}
}Inside each tab's This example makes the pager the source of selection. A tab-bar click should call Relevant APIs: TabNavigator and its per-tab state helper, ScreenModel, and Foundation Pager. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I currently have a HorizontalPager in my Screen. I want each page in the Pager to correspond to a Screen/Tab and ViewModel. What should I do? Through my research, it seems that I haven't found a very suitable solution.
All reactions