@craft-native/ios 0.0.196 → 0.0.197

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@craft-native/ios",
3
- "version": "0.0.196",
3
+ "version": "0.0.197",
4
4
  "homepage": "https://github.com/craft-native/craft/tree/main/packages/ios#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,10 +21,6 @@ final class CraftNativeFlatList: UICollectionView, UICollectionViewDelegateFlowL
21
21
  private(set) var representedIdentity: String?
22
22
  private(set) var hostedView: UIView?
23
23
  var onRecycle: ((String) -> Void)?
24
- /// The width (or, sideways, height) the list gives this row, so a row
25
- /// is measured at the list's width rather than the layout's estimate.
26
- var fittingExtent: CGFloat?
27
-
28
24
  override func prepareForReuse() {
29
25
  super.prepareForReuse()
30
26
  releaseHostedView()
@@ -63,6 +59,12 @@ final class CraftNativeFlatList: UICollectionView, UICollectionViewDelegateFlowL
63
59
  // collection view ancestor.
64
60
  var ancestor = superview
65
61
  while let view = ancestor, !(view is UICollectionView) { ancestor = view.superview }
62
+ // A reusable cell can be measured during UIKit's invalidation,
63
+ // before layoutSubviews updates visible cells. Derive the extent
64
+ // from the live list bounds on every self-sizing pass.
65
+ let list = ancestor as? CraftNativeFlatList
66
+ let isChrome = representedIdentity.flatMap { list?.itemsByIdentity[$0]?.isChrome } ?? false
67
+ let fittingExtent = list?.itemExtent(isChrome: isChrome)
66
68
  if let collectionView = ancestor as? UICollectionView,
67
69
  let flowLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout,
68
70
  flowLayout.scrollDirection == .horizontal {
@@ -155,7 +157,6 @@ final class CraftNativeFlatList: UICollectionView, UICollectionViewDelegateFlowL
155
157
  let renderItem = self.renderItem else { return UICollectionViewCell() }
156
158
  let view = renderItem(item.node, identity, cell.hostedView)
157
159
  cell.onRecycle = self.recycleItem
158
- cell.fittingExtent = self.itemExtent(isChrome: item.isChrome)
159
160
  cell.host(view, identity: identity)
160
161
  return cell
161
162
  }
@@ -214,19 +215,6 @@ final class CraftNativeFlatList: UICollectionView, UICollectionViewDelegateFlowL
214
215
  if flowLayout.estimatedItemSize != estimate, bounds.width > 0 {
215
216
  flowLayout.estimatedItemSize = estimate
216
217
  }
217
- // Cells can outlive a change to the list's width (including its first
218
- // constrained parent layout). Self-sizing must use the current extent,
219
- // or UIKit repeatedly receives a preferred width wider than the list.
220
- var changedExtent = false
221
- for case let cell as Cell in visibleCells {
222
- guard let identity = cell.representedIdentity, let item = itemsByIdentity[identity] else { continue }
223
- let extent = itemExtent(isChrome: item.isChrome)
224
- if cell.fittingExtent != extent {
225
- cell.fittingExtent = extent
226
- changedExtent = true
227
- }
228
- }
229
- if changedExtent { flowLayout.invalidateLayout() }
230
218
  super.layoutSubviews()
231
219
  craftApplyCornerRadius()
232
220
  }