diff --git a/CHANGELOG.md b/CHANGELOG.md index f91d7ef85d..7743cb2c55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Fixed: - Fix a layout bug where `Row` and `Column` layouts reported the wrong dimensions if their subviews could wrap. - Correctly update the layout when a Box's child's modifiers are removed. - Fix a layout bug where children of `Box` containers were not measured properly. +- Fix a bug where `LazyColumn` didn't honor child widget resizes. Breaking: - Replace `CodeListener` with a new `DynamicContentWidgetFactory` API. Now loading and crashed views work like all other child widgets. diff --git a/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_RTL_testLayoutHandlesChildResizes_v1.png b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_RTL_testLayoutHandlesChildResizes_v1.png new file mode 100644 index 0000000000..60daf02489 --- /dev/null +++ b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_RTL_testLayoutHandlesChildResizes_v1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42b3b4cbbdc49e1ae57480170ae7123211a7c3382124464904493c72f310e88e +size 4027 diff --git a/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_RTL_testLayoutHandlesChildResizes_v2.png b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_RTL_testLayoutHandlesChildResizes_v2.png new file mode 100644 index 0000000000..780e3fe225 --- /dev/null +++ b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_RTL_testLayoutHandlesChildResizes_v2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:26eb384f334000d653501344cf7ecad9766e7c2046d8313e3d98f63aff672072 +size 3992 diff --git a/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testLayoutHandlesChildResizes_v1.png b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testLayoutHandlesChildResizes_v1.png new file mode 100644 index 0000000000..60daf02489 --- /dev/null +++ b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testLayoutHandlesChildResizes_v1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42b3b4cbbdc49e1ae57480170ae7123211a7c3382124464904493c72f310e88e +size 4027 diff --git a/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testLayoutHandlesChildResizes_v2.png b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testLayoutHandlesChildResizes_v2.png new file mode 100644 index 0000000000..780e3fe225 --- /dev/null +++ b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testLayoutHandlesChildResizes_v2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:26eb384f334000d653501344cf7ecad9766e7c2046d8313e3d98f63aff672072 +size 3992 diff --git a/redwood-layout-shared-test/src/commonMain/kotlin/app/cash/redwood/layout/AbstractFlexContainerTest.kt b/redwood-layout-shared-test/src/commonMain/kotlin/app/cash/redwood/layout/AbstractFlexContainerTest.kt index 39d19df3d4..ea7287cf5a 100644 --- a/redwood-layout-shared-test/src/commonMain/kotlin/app/cash/redwood/layout/AbstractFlexContainerTest.kt +++ b/redwood-layout-shared-test/src/commonMain/kotlin/app/cash/redwood/layout/AbstractFlexContainerTest.kt @@ -31,6 +31,7 @@ import app.cash.redwood.snapshot.testing.Red import app.cash.redwood.snapshot.testing.Snapshotter import app.cash.redwood.snapshot.testing.TestWidgetFactory import app.cash.redwood.snapshot.testing.argb +import app.cash.redwood.snapshot.testing.color import app.cash.redwood.snapshot.testing.text import app.cash.redwood.ui.Margin import app.cash.redwood.ui.Px @@ -48,6 +49,8 @@ abstract class AbstractFlexContainerTest { protected val defaultBackgroundColor = argb(51, 0, 0, 255) + protected open val viewMeasurementIsImpreciseAfterAnItemSizeChanges = false + abstract fun flexContainer( direction: FlexDirection, backgroundColor: Int = defaultBackgroundColor, @@ -651,10 +654,12 @@ abstract class AbstractFlexContainerTest { val bMeasureCountV2 = b.measureCount val cMeasureCountV2 = c.measureCount - // Only 'b' is measured again. - assertEquals(aMeasureCountV1, aMeasureCountV2) - assertTrue(bMeasureCountV1 <= bMeasureCountV2) - assertEquals(cMeasureCountV1, cMeasureCountV2) + // Only 'b' is measured again. Except for UIViewLazyList which measures more. + if (!viewMeasurementIsImpreciseAfterAnItemSizeChanges) { + assertEquals(aMeasureCountV1, aMeasureCountV2) + assertTrue(bMeasureCountV1 <= bMeasureCountV2) + assertEquals(cMeasureCountV1, cMeasureCountV2) + } snapshotter.snapshot("v3") val aMeasureCountV3 = a.measureCount @@ -775,6 +780,42 @@ abstract class AbstractFlexContainerTest { snapshotter.snapshot("v2") } + @Test fun testLayoutHandlesChildResizes() { + val column = flexContainer(FlexDirection.Column) + .apply { + width(Constraint.Fill) + height(Constraint.Fill) + crossAxisAlignment(CrossAxisAlignment.Stretch) + } + val snapshotter = snapshotter(column.value) + + val row0 = widgetFactory.color(Red, 100.dp, 100.dp) + column.add(row0) + + val row1 = widgetFactory.color(Green, 80.dp, 80.dp) + column.add(row1) + + val row2 = widgetFactory.color(Blue, 60.dp, 60.dp) + column.add(row2) + + val row3 = widgetFactory.color(Red, 40.dp, 40.dp) + column.add(row3) + + column.onEndChanges() + snapshotter.snapshot("v1") + + row0.height(40.dp) + row0.width(40.dp) + row1.height(60.dp) + row1.width(60.dp) + row2.height(80.dp) + row2.width(80.dp) + row3.height(100.dp) + row3.width(100.dp) + + snapshotter.snapshot("v2") + } + /** * When a child widget's intrinsic size won't fit in the available space, what happens? We can * either let it have its requested size anyway (and overrun the available space) or we confine it diff --git a/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testLayoutHandlesChildResizes.v1.png b/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testLayoutHandlesChildResizes.v1.png new file mode 100644 index 0000000000..846852c58b --- /dev/null +++ b/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testLayoutHandlesChildResizes.v1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:26600d51a113d807212a1833a733f6f8a4ce350cc761a457bed16abfbbb80096 +size 66344 diff --git a/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testLayoutHandlesChildResizes.v2.png b/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testLayoutHandlesChildResizes.v2.png new file mode 100644 index 0000000000..0b3f380e73 --- /dev/null +++ b/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testLayoutHandlesChildResizes.v2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20185482127b0b55dd1cdeae1126d3ba895ab5ddaa673cc484fad759d7ebdf84 +size 66598 diff --git a/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_RTL_testLayoutHandlesChildResizes_v1.png b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_RTL_testLayoutHandlesChildResizes_v1.png new file mode 100644 index 0000000000..70d309dfe2 --- /dev/null +++ b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_RTL_testLayoutHandlesChildResizes_v1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12f19a1e2bc21e4c6a136e14efd749c443840cff074af5bb4c5401e082c24a8b +size 4059 diff --git a/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_RTL_testLayoutHandlesChildResizes_v2.png b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_RTL_testLayoutHandlesChildResizes_v2.png new file mode 100644 index 0000000000..1045314f12 --- /dev/null +++ b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_RTL_testLayoutHandlesChildResizes_v2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e975caa6125173e5f4536bcb5f1cee741b645ca52ee39fbd123cfdee485f3150 +size 4015 diff --git a/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testLayoutHandlesChildResizes_v1.png b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testLayoutHandlesChildResizes_v1.png new file mode 100644 index 0000000000..70d309dfe2 --- /dev/null +++ b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testLayoutHandlesChildResizes_v1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12f19a1e2bc21e4c6a136e14efd749c443840cff074af5bb4c5401e082c24a8b +size 4059 diff --git a/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testLayoutHandlesChildResizes_v2.png b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testLayoutHandlesChildResizes_v2.png new file mode 100644 index 0000000000..1045314f12 --- /dev/null +++ b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testLayoutHandlesChildResizes_v2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e975caa6125173e5f4536bcb5f1cee741b645ca52ee39fbd123cfdee485f3150 +size 4015 diff --git a/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_RTL_testLayoutHandlesChildResizes_v1.png b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_RTL_testLayoutHandlesChildResizes_v1.png new file mode 100644 index 0000000000..6db08cc1ed --- /dev/null +++ b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_RTL_testLayoutHandlesChildResizes_v1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6736ae8bb46937be3c189a7e223114aa4c263fa72bb576bc1a052fff55172b9f +size 4554 diff --git a/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_RTL_testLayoutHandlesChildResizes_v2.png b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_RTL_testLayoutHandlesChildResizes_v2.png new file mode 100644 index 0000000000..1717bd6e2c --- /dev/null +++ b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_RTL_testLayoutHandlesChildResizes_v2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c479419f809c174d347ae5c655fb32180f7b5960f48cbde9e8bcd3a54cb5d4f +size 4526 diff --git a/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testLayoutHandlesChildResizes_v1.png b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testLayoutHandlesChildResizes_v1.png new file mode 100644 index 0000000000..c10086f9df --- /dev/null +++ b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testLayoutHandlesChildResizes_v1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:511453ec5fdefd584856ef97bd17ed9f470dbc9dc9c8e6f957598966823a5dbb +size 4497 diff --git a/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testLayoutHandlesChildResizes_v2.png b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testLayoutHandlesChildResizes_v2.png new file mode 100644 index 0000000000..71b26743b2 --- /dev/null +++ b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testLayoutHandlesChildResizes_v2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:097606fafb740546d54780a4d87c12df1dfc2e3b6e280c1d82eee87b2a7621b8 +size 4479 diff --git a/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testChildWithUpdatedProperty.updated.png b/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testChildWithUpdatedProperty.updated.png index 774ebdc233..c4b9a515b2 100644 --- a/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testChildWithUpdatedProperty.updated.png +++ b/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testChildWithUpdatedProperty.updated.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d930492c69fcc84cd8129fcfb5ded815a9c202579d6077af06ae4e6b59eca4f -size 70697 +oid sha256:90e5f1f941bd7fe01603d151dc055d5542680485f2a8f4b0624f4ed08d8957a7 +size 70543 diff --git a/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testLayoutHandlesChildResizes.v1.png b/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testLayoutHandlesChildResizes.v1.png new file mode 100644 index 0000000000..846852c58b --- /dev/null +++ b/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testLayoutHandlesChildResizes.v1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:26600d51a113d807212a1833a733f6f8a4ce350cc761a457bed16abfbbb80096 +size 66344 diff --git a/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testLayoutHandlesChildResizes.v2.png b/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testLayoutHandlesChildResizes.v2.png new file mode 100644 index 0000000000..0b3f380e73 --- /dev/null +++ b/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testLayoutHandlesChildResizes.v2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20185482127b0b55dd1cdeae1126d3ba895ab5ddaa673cc484fad759d7ebdf84 +size 66598 diff --git a/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testRecursiveLayoutHandlesResizes.v2.png b/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testRecursiveLayoutHandlesResizes.v2.png index 96a67b0a8f..aba76cb157 100644 --- a/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testRecursiveLayoutHandlesResizes.v2.png +++ b/redwood-lazylayout-uiview/RedwoodLazylayoutUIViewTests/__Snapshots__/UIViewLazyListAsFlexContainerTestHost/testRecursiveLayoutHandlesResizes.v2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:106ecd41ecc0fef54ef4d276bd711ca9303c3b25c1d49f9f318bd898bd6f23ae -size 74954 +oid sha256:1a32ab82587b6a2d091db032b45dbcd593cc327133e77cfbb7fd2c3d942d2e45 +size 76976 diff --git a/redwood-lazylayout-uiview/src/commonMain/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt b/redwood-lazylayout-uiview/src/commonMain/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt index b047f7901c..d9da6ff0c2 100644 --- a/redwood-lazylayout-uiview/src/commonMain/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt +++ b/redwood-lazylayout-uiview/src/commonMain/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt @@ -32,6 +32,7 @@ import app.cash.redwood.lazylayout.widget.LazyListUpdateProcessor.Binding import app.cash.redwood.lazylayout.widget.RefreshableLazyList import app.cash.redwood.ui.Margin import app.cash.redwood.widget.ChangeListener +import app.cash.redwood.widget.ResizableWidget import app.cash.redwood.widget.Widget import kotlinx.cinterop.CValue import kotlinx.cinterop.ObjCClass @@ -121,8 +122,8 @@ internal class UIViewLazyList : } } - private var updateProcessor: LazyListUpdateProcessor? = object : LazyListUpdateProcessor() { - override fun createPlaceholder(original: UIView) = SizeOnlyPlaceholder(original) + internal inner class UpdateProcessor : LazyListUpdateProcessor() { + override fun createPlaceholder(original: UIView): UIView = SizeOnlyPlaceholder(original) override fun insertRows(index: Int, count: Int) { rowCount += count @@ -155,7 +156,7 @@ internal class UIViewLazyList : } override fun setContent(view: LazyListContainerCell, widget: Widget?) { - view.setContent(widget?.value) + view.setContent(widget) } override fun detach(view: LazyListContainerCell) { @@ -165,8 +166,21 @@ internal class UIViewLazyList : override fun detach() { this@UIViewLazyList.detach() } + + fun invalidateSize(binding: Binding) { + val tableView = this@UIViewLazyList.tableView ?: return + val lazyListContainerCell = binding.view ?: return + val indexPath = tableView.indexPathForCell(lazyListContainerCell) ?: return + + tableView.reloadRowsAtIndexPaths( + listOf(indexPath), + UITableViewRowAnimationNone, + ) + } } + private var updateProcessor: UpdateProcessor? = UpdateProcessor() + /** Cache of [LazyListUpdateProcessor.size] so we can return it after [detach]. */ private var rowCount = 0 @@ -336,6 +350,7 @@ internal class LazyListContainerCell( reuseIdentifier: String?, ) : UITableViewCell(style, reuseIdentifier) { internal var binding: Binding? = null + private var content: Widget? = null override fun initWithStyle( style: UITableViewCellStyle, @@ -379,33 +394,48 @@ internal class LazyListContainerCell( override fun layoutSubviews() { super.layoutSubviews() - val content = contentView.subviews.firstOrNull() as UIView? ?: return - content.setFrame(bounds) + content?.value?.setFrame(bounds) contentView.setFrame(bounds) } override fun sizeThatFits(size: CValue): CValue { - val content = contentView.subviews.firstOrNull() as UIView? ?: return super.sizeThatFits(size) - return content.sizeThatFits(size) + val content = this.content ?: return super.sizeThatFits(size) + return content.value.sizeThatFits(size) } - internal fun setContent(content: UIView?) { - removeAllSubviews() - if (content != null) { - contentView.addSubview(content) + internal fun setContent(widget: Widget?) { + val previous = this.content + if (previous != null) { + previous.value.removeFromSuperview() + if (previous is ResizableWidget) { + previous.sizeListener = null + } + } + this.selectedBackgroundView = null + + this.content = widget + if (widget != null) { + contentView.addSubview(widget.value) + if (widget is ResizableWidget) { + widget.sizeListener = object : ResizableWidget.SizeListener { + override fun invalidateSize() { + val binding = binding ?: return + (binding.processor as UIViewLazyList.UpdateProcessor).invalidateSize(binding) + } + } + } } setNeedsLayout() } - private fun removeAllSubviews() { - contentView.subviews.forEach { - (it as UIView).removeFromSuperview() + internal fun detach() { + val previous = content + if (previous is ResizableWidget) { + previous.sizeListener = null } - selectedBackgroundView = null - } - internal fun detach() { - binding = null // Break a reference cycle. + this.binding = null // Break a reference cycle. + this.content = null // Break a reference cycle. } } diff --git a/redwood-lazylayout-uiview/src/commonTest/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyListAsFlexContainerTest.kt b/redwood-lazylayout-uiview/src/commonTest/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyListAsFlexContainerTest.kt index 7752fcb384..ce51630f18 100644 --- a/redwood-lazylayout-uiview/src/commonTest/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyListAsFlexContainerTest.kt +++ b/redwood-lazylayout-uiview/src/commonTest/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyListAsFlexContainerTest.kt @@ -39,6 +39,8 @@ class UIViewLazyListAsFlexContainerTest( private val lazyLayoutWidgetFactory = UIViewRedwoodLazyLayoutWidgetFactory() + override val viewMeasurementIsImpreciseAfterAnItemSizeChanges = true + override fun flexContainer( direction: FlexDirection, backgroundColor: Int, diff --git a/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListAsFlexContainerTest_RTL_testLayoutHandlesChildResizes_v1.png b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListAsFlexContainerTest_RTL_testLayoutHandlesChildResizes_v1.png new file mode 100644 index 0000000000..70d309dfe2 --- /dev/null +++ b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListAsFlexContainerTest_RTL_testLayoutHandlesChildResizes_v1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12f19a1e2bc21e4c6a136e14efd749c443840cff074af5bb4c5401e082c24a8b +size 4059 diff --git a/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListAsFlexContainerTest_RTL_testLayoutHandlesChildResizes_v2.png b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListAsFlexContainerTest_RTL_testLayoutHandlesChildResizes_v2.png new file mode 100644 index 0000000000..1045314f12 --- /dev/null +++ b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListAsFlexContainerTest_RTL_testLayoutHandlesChildResizes_v2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e975caa6125173e5f4536bcb5f1cee741b645ca52ee39fbd123cfdee485f3150 +size 4015 diff --git a/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListAsFlexContainerTest_testLayoutHandlesChildResizes_v1.png b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListAsFlexContainerTest_testLayoutHandlesChildResizes_v1.png new file mode 100644 index 0000000000..70d309dfe2 --- /dev/null +++ b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListAsFlexContainerTest_testLayoutHandlesChildResizes_v1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12f19a1e2bc21e4c6a136e14efd749c443840cff074af5bb4c5401e082c24a8b +size 4059 diff --git a/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListAsFlexContainerTest_testLayoutHandlesChildResizes_v2.png b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListAsFlexContainerTest_testLayoutHandlesChildResizes_v2.png new file mode 100644 index 0000000000..1045314f12 --- /dev/null +++ b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListAsFlexContainerTest_testLayoutHandlesChildResizes_v2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e975caa6125173e5f4536bcb5f1cee741b645ca52ee39fbd123cfdee485f3150 +size 4015 diff --git a/redwood-lazylayout-widget/api/redwood-lazylayout-widget.api b/redwood-lazylayout-widget/api/redwood-lazylayout-widget.api index a938adb1e8..c4c716502a 100644 --- a/redwood-lazylayout-widget/api/redwood-lazylayout-widget.api +++ b/redwood-lazylayout-widget/api/redwood-lazylayout-widget.api @@ -45,6 +45,7 @@ public abstract class app/cash/redwood/lazylayout/widget/LazyListUpdateProcessor public final class app/cash/redwood/lazylayout/widget/LazyListUpdateProcessor$Binding { public final fun bind (Ljava/lang/Object;)V public final fun detach ()V + public final fun getProcessor ()Lapp/cash/redwood/lazylayout/widget/LazyListUpdateProcessor; public final fun getView ()Ljava/lang/Object; public final fun isBound ()Z public final fun unbind ()V diff --git a/redwood-lazylayout-widget/api/redwood-lazylayout-widget.klib.api b/redwood-lazylayout-widget/api/redwood-lazylayout-widget.klib.api index 9e9861513a..cc75c6dd5c 100644 --- a/redwood-lazylayout-widget/api/redwood-lazylayout-widget.klib.api +++ b/redwood-lazylayout-widget/api/redwood-lazylayout-widget.klib.api @@ -75,6 +75,8 @@ abstract class <#A: kotlin/Any, #B: kotlin/Any> app.cash.redwood.lazylayout.widg final class <#A1: kotlin/Any, #B1: kotlin/Any> Binding { // app.cash.redwood.lazylayout.widget/LazyListUpdateProcessor.Binding|null[0] final val isBound // app.cash.redwood.lazylayout.widget/LazyListUpdateProcessor.Binding.isBound|{}isBound[0] final fun (): kotlin/Boolean // app.cash.redwood.lazylayout.widget/LazyListUpdateProcessor.Binding.isBound.|(){}[0] + final val processor // app.cash.redwood.lazylayout.widget/LazyListUpdateProcessor.Binding.processor|{}processor[0] + final fun (): app.cash.redwood.lazylayout.widget/LazyListUpdateProcessor<#A1, #B1> // app.cash.redwood.lazylayout.widget/LazyListUpdateProcessor.Binding.processor.|(){}[0] final var view // app.cash.redwood.lazylayout.widget/LazyListUpdateProcessor.Binding.view|{}view[0] final fun (): #A1? // app.cash.redwood.lazylayout.widget/LazyListUpdateProcessor.Binding.view.|(){}[0] diff --git a/redwood-lazylayout-widget/src/commonMain/kotlin/app/cash/redwood/lazylayout/widget/LazyListUpdateProcessor.kt b/redwood-lazylayout-widget/src/commonMain/kotlin/app/cash/redwood/lazylayout/widget/LazyListUpdateProcessor.kt index c1d069a7ad..3c8053a15e 100644 --- a/redwood-lazylayout-widget/src/commonMain/kotlin/app/cash/redwood/lazylayout/widget/LazyListUpdateProcessor.kt +++ b/redwood-lazylayout-widget/src/commonMain/kotlin/app/cash/redwood/lazylayout/widget/LazyListUpdateProcessor.kt @@ -461,7 +461,7 @@ public abstract class LazyListUpdateProcessor { * assumes that a view that is discarded will never be bound again. */ public class Binding internal constructor( - internal val processor: LazyListUpdateProcessor, + public val processor: LazyListUpdateProcessor, internal var isPlaceholder: Boolean = false, ) { /** The currently-bound view. Null if this is not on-screen. */