Created
March 19, 2023 19:27
-
-
Save Ahmad-Hamwi/62726fbe94b1f058532c9ae92540dda1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun TabSyncComposeScreen(categories: List<Category>) { | |
val (selectedTabIndex, setSelectedTabIndex, lazyListState) = tabSyncMediator( | |
mutableListOf(0, 2, 4), //Mandatory. The indices of lazy list items to sync the tabs with | |
tabsCount = 3, //Optional. To check for viability of the synchronization with the tabs. Optimal when equals the count of syncedIndices. | |
lazyListState = rememberLazyListState(), //Optional. To provide your own LazyListState. Defaults to rememberLazyListState(). | |
smoothScroll = true, // Optional. To make the auto scroll smooth or not when clicking tabs. Defaults to true | |
) | |
Column { | |
MyTabBar( | |
categories = categories, | |
selectedTabIndex = selectedTabIndex, | |
onTabClicked = { index, _ -> setSelectedTabIndex(index) } | |
) | |
MyLazyList(categories, lazyListState) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment