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
fun LazyListState.findFirstFullyVisibleItemIndex(): Int = findFullyVisibleItemIndex(false) | |
fun LazyListState.findLastFullyVisibleItemIndex(): Int = findFullyVisibleItemIndex(true) | |
fun LazyListState.findFullyVisibleItemIndex(reversed: Boolean): Int { | |
layoutInfo.visibleItemsInfo | |
.run { if (reversed) reversed() else this } | |
.forEach { itemInfo -> | |
val itemStartOffset = itemInfo.offset | |
val itemEndOffset = itemInfo.offset + itemInfo.size |
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
operator fun component2(): (Int) -> Unit = { | |
... | |
coroutineScope.launch { | |
if (smoothScroll) { | |
lazyListState.animateScrollToItem(syncedIndices[selectedTabIndex]) | |
} else { | |
lazyListState.scrollToItem(syncedIndices[selectedTabIndex]) | |
} | |
} |
OlderNewer