Skip to content

Commit

Permalink
Support circular lazy lists
Browse files Browse the repository at this point in the history
Summary:
We are adding the ability to have circular lazy lists. This was already existing in Sections and now we are exposing it to `LazyList`.

For now we are not considering grids because there is some crash when we do it.

Reviewed By: pentiumao

Differential Revision: D57720803

fbshipit-source-id: 7c7c6f605e466ba8d947d356ecf75c7ca5e7be9e
  • Loading branch information
Fabio Carballo authored and facebook-github-bot committed May 30, 2024
1 parent 482b194 commit 9ee6804
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ abstract class CollectionLayout(
val canMeasureRecycler: Boolean = false,
mainAxisWrapContent: Boolean = false,
preAllocationHandler: PreAllocationHandler?,
isCircular: Boolean
) {
internal abstract fun createRecyclerConfigurationBuilder(): RecyclerConfiguration.Builder

Expand All @@ -69,7 +70,8 @@ abstract class CollectionLayout(
preAllocationHandler = preAllocationHandler,
incrementalMountEnabled = isIncrementalMountEnabled),
rangeRatio = rangeRatio ?: RecyclerBinderConfig.DEFAULT_RANGE_RATIO,
wrapContent = mainAxisWrapContent))
wrapContent = mainAxisWrapContent,
isCircular = isCircular))
.useBackgroundChangeSets(useBackgroundChangeSets)
.build())
.build()
Expand Down Expand Up @@ -130,6 +132,7 @@ internal object CollectionLayouts {
crossAxisWrapMode: CrossAxisWrapMode = CrossAxisWrapMode.NoWrap,
mainAxisWrapContent: Boolean = false,
preAllocationHandler: PreAllocationHandler?,
isCircular: Boolean
): CollectionLayout =
object :
CollectionLayout(
Expand All @@ -142,7 +145,8 @@ internal object CollectionLayouts {
hasDynamicItemHeight = crossAxisWrapMode.hasDynamicItemHeight,
canMeasureRecycler = crossAxisWrapMode.canMeasureRecycler,
mainAxisWrapContent = mainAxisWrapContent,
preAllocationHandler = preAllocationHandler) {
preAllocationHandler = preAllocationHandler,
isCircular = isCircular) {
override fun createRecyclerConfigurationBuilder(): RecyclerConfiguration.Builder =
ListRecyclerConfiguration.create()
.snapMode(snapMode)
Expand Down Expand Up @@ -181,7 +185,8 @@ internal object CollectionLayouts {
rangeRatio = rangeRatio,
useBackgroundChangeSets = useBackgroundChangeSets,
isReconciliationEnabled = isReconciliationEnabled,
preAllocationHandler = preAllocationHandler) {
preAllocationHandler = preAllocationHandler,
isCircular = false) {
override fun createRecyclerConfigurationBuilder(): RecyclerConfiguration.Builder =
GridRecyclerConfiguration.create()
.snapMode(snapMode)
Expand Down Expand Up @@ -224,7 +229,7 @@ internal object CollectionLayouts {
isReconciliationEnabled = isReconciliationEnabled,
isIncrementalMountEnabled = isIncrementalMountEnabled,
preAllocationHandler = preAllocationHandler,
) {
isCircular = false) {
override fun createRecyclerConfigurationBuilder(): RecyclerConfiguration.Builder =
StaggeredGridRecyclerConfiguration.create().numSpans(spans).gapStrategy(gapStrategy)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ inline fun ResourcesScope.LazyList(
alwaysDetectDuplicates: Boolean = false,
fadingEdgeLength: Dimen? = null,
shouldExcludeFromIncrementalMount: Boolean = false,
isCircular: Boolean = false,
init: LazyListScope.() -> Unit
): Component {
val lazyListScope = LazyListScope(context).apply { init() }
Expand All @@ -92,7 +93,8 @@ inline fun ResourcesScope.LazyList(
isReconciliationEnabled = isReconciliationEnabled,
preAllocationHandler = preAllocationHandler,
crossAxisWrapMode = crossAxisWrapMode,
mainAxisWrapContent = mainAxisWrapContent),
mainAxisWrapContent = mainAxisWrapContent,
isCircular = isCircular),
itemAnimator,
itemDecoration,
clipToPadding,
Expand Down

0 comments on commit 9ee6804

Please sign in to comment.