@onekeyfe/react-native-native-list 6.7.0-51 → 6.7.0-53

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/docs/SPEC.md CHANGED
@@ -1580,6 +1580,11 @@ it. The first numeric measurement, including a genuine zero, is authoritative
1580
1580
  and retains ordinary dynamic growth and shrink behavior. Legacy four- and
1581
1581
  six-number arrays remain accepted. Only header slot 0 may be null, and the
1582
1582
  wrapper and native binary must match for this pending-header protocol.
1583
+ When the vertical iOS collection view first obtains positive bounds in
1584
+ `layoutSubviews`, it emits `OneKeyNativeScrollViewDidBecomeReady` before
1585
+ executing pending scroll requests or laying out container slots so an enclosing
1586
+ `CollapsiblePagerView` can synchronously attach and apply top insets, offset
1587
+ alignment, and sticky heights during the same layout pass.
1583
1588
 
1584
1589
  Android uses ConcatAdapter with three single-item slot adapters around the existing
1585
1590
  data adapter; adapter binding indices stay local while layout-manager positions
@@ -285,6 +285,10 @@ content; `lineGap` separates content text rows (primary/secondary per data colum
285
285
  for activity, the native failure label or rich title badges; Web has no activity
286
286
  badge target);
287
287
  `trailingGap` separates trailing values/controls (title/badge to status for rail).
288
+ For identity those are the trailing accessories: a `valuePair` is one accessory,
289
+ so the gap sits between it and its neighbours and never between its two lines,
290
+ on every platform. For activity the gap separates `primaryAmount` from
291
+ `secondaryAmount`.
288
292
  `walletGroup` padding applies only to the group; it never cascades into members.
289
293
  Composite metric-card `lineGap` separates heading/metric blocks and dividers; it
290
294
  does not change the typography or inner label/value gap of each metric.
@@ -973,6 +973,7 @@ final class NativeListView: UIView {
973
973
  guard !disposed,
974
974
  window != nil,
975
975
  collectionView.delegate === self,
976
+ flowLayout.scrollDirection == .vertical,
976
977
  collectionView.bounds.width > 0,
977
978
  collectionView.bounds.height > 0 else { return }
978
979
  NotificationCenter.default.post(
@@ -1007,11 +1008,11 @@ final class NativeListView: UIView {
1007
1008
  configureLayout(config)
1008
1009
  if lastLayoutDirection != direction { rebindRowsForLayoutDirection(config) }
1009
1010
  }
1010
- performPendingScrollIfNeeded()
1011
- layoutContainerSlots()
1012
1011
  if !hadUsableBounds && collectionView.bounds.width > 0 && collectionView.bounds.height > 0 {
1013
1012
  notifyPagerScrollViewReadyIfNeeded()
1014
1013
  }
1014
+ performPendingScrollIfNeeded()
1015
+ layoutContainerSlots()
1015
1016
  }
1016
1017
 
1017
1018
  // A layout-direction change may arrive without a layout pass (semantic attribute or trait).
@@ -3613,7 +3614,9 @@ final class NativeListFlowLayout: UICollectionViewFlowLayout {
3613
3614
  guard scrollDirection == .horizontal, let collectionView else { return }
3614
3615
 
3615
3616
  var nextX = sectionInset.left
3616
- let itemCount = collectionView.numberOfItems(inSection: 0)
3617
+ let itemCount = collectionView.numberOfSections > 0
3618
+ ? collectionView.numberOfItems(inSection: 0)
3619
+ : 0
3617
3620
  for item in 0..<itemCount {
3618
3621
  let indexPath = IndexPath(item: item, section: 0)
3619
3622
  guard let attributes = super.layoutAttributesForItem(at: indexPath)?.copy()
@@ -1340,6 +1340,50 @@ final class NativeListLifecycleTests: XCTestCase {
1340
1340
  view.dispose()
1341
1341
  }
1342
1342
 
1343
+ func testFirstUsableBoundsNotifiesPagerBeforeSlotLayout() throws {
1344
+ let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 390, height: 844))
1345
+ let root = UIViewController()
1346
+ window.rootViewController = root
1347
+ window.isHidden = false
1348
+ let view = NativeListView(frame: .zero)
1349
+ root.view.addSubview(view)
1350
+ defer {
1351
+ view.dispose()
1352
+ view.removeFromSuperview()
1353
+ window.rootViewController = nil
1354
+ window.isHidden = true
1355
+ }
1356
+
1357
+ let header = UIView(frame: CGRect(x: 0, y: 0, width: 390, height: 65))
1358
+ view.mountContainerSlot(header, atIndex: 0)
1359
+ view.setContainerSlotHeightsJson("[65,0,0,0,0,0]")
1360
+ view.applySnapshotJson(try scrollingSnapshot(count: 6))
1361
+
1362
+ let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
1363
+ let owner = NSObject()
1364
+ var readyCount = 0
1365
+ let observer = NotificationCenter.default.addObserver(
1366
+ forName: Notification.Name("OneKeyNativeScrollViewDidBecomeReady"),
1367
+ object: list,
1368
+ queue: nil
1369
+ ) { _ in
1370
+ readyCount += 1
1371
+ view.setPagerStickyHeight(52, forOwner: owner)
1372
+ list.contentInset = UIEdgeInsets(top: 345, left: 0, bottom: 0, right: 0)
1373
+ list.setContentOffset(CGPoint(x: 0, y: -345), animated: false)
1374
+ }
1375
+ defer { NotificationCenter.default.removeObserver(observer) }
1376
+
1377
+ view.frame = CGRect(x: 0, y: 0, width: 390, height: 697)
1378
+ view.layoutIfNeeded()
1379
+
1380
+ let host = try XCTUnwrap(header.superview)
1381
+ XCTAssertEqual(readyCount, 1)
1382
+ XCTAssertEqual(list.contentInset.top, 345, accuracy: 0.01)
1383
+ XCTAssertEqual(list.contentOffset.y, -345, accuracy: 0.01)
1384
+ XCTAssertNil(host.layer.mask)
1385
+ }
1386
+
1343
1387
  func testSidecarCentersRowsWhenConfiguredBeforeFirstWidth() throws {
1344
1388
  try assertHomeSidecarGeometry(sidecarBeforeFirstLayout: true)
1345
1389
  }
@@ -269,7 +269,9 @@ function applyIdentityStyle(body, row) {
269
269
  }
270
270
  if (box.trailingGap !== undefined) {
271
271
  const gap = String(box.trailingGap) + 'px';
272
- body.querySelectorAll('.ok-native-list-accessories, .ok-native-list-amounts').forEach(trailing => {
272
+ // The accessory row only. A value pair is one accessory whose two lines
273
+ // are a flex column, so a gap there would push the lines apart.
274
+ body.querySelectorAll('.ok-native-list-accessories').forEach(trailing => {
273
275
  trailing.style.gap = gap;
274
276
  });
275
277
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-native-list",
3
- "version": "6.7.0-51",
3
+ "version": "6.7.0-53",
4
4
  "description": "Template-driven native RecyclerView and UICollectionView for React Native",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",
@@ -505,10 +505,10 @@ function applyIdentityStyle(body: HTMLElement, row: IdentityRow) {
505
505
  }
506
506
  if (box.trailingGap !== undefined) {
507
507
  const gap = String(box.trailingGap) + 'px';
508
+ // The accessory row only. A value pair is one accessory whose two lines
509
+ // are a flex column, so a gap there would push the lines apart.
508
510
  body
509
- .querySelectorAll<HTMLElement>(
510
- '.ok-native-list-accessories, .ok-native-list-amounts'
511
- )
511
+ .querySelectorAll<HTMLElement>('.ok-native-list-accessories')
512
512
  .forEach((trailing) => {
513
513
  trailing.style.gap = gap;
514
514
  });