@onekeyfe/react-native-native-list 6.8.0-3 → 6.8.0-31
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/android/build.gradle +3 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +18 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +12 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +166 -36
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +8 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +6 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +21 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +24 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListRowUpdates.kt +34 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +11 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentLayout.kt +71 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentsView.kt +126 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +84 -9
- package/android/src/main/res/values/native_scroll_coordinator_ids.xml +1 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentitySubtitleBindingTest.kt +177 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +2 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListTitleSegmentLayoutTest.kt +130 -0
- package/docs/ROW_TEMPLATES.md +8 -1
- package/docs/SPEC.md +312 -5
- package/docs/STYLE_SPEC.md +7 -1
- package/ios/NativeListAccessoryStack.swift +22 -0
- package/ios/NativeListActivityDetailsView.swift +45 -1
- package/ios/NativeListDataRowRenderer.swift +12 -5
- package/ios/NativeListIdentityRenderer.swift +145 -66
- package/ios/NativeListLeadingVisual.swift +8 -0
- package/ios/NativeListMarketRenderer.swift +6 -2
- package/ios/NativeListModels.swift +7 -0
- package/ios/NativeListResolvedText.swift +9 -7
- package/ios/NativeListSectionHeaderRenderer.swift +9 -43
- package/ios/NativeListTextStyles.swift +72 -12
- package/ios/NativeListTitleSegmentLayout.swift +72 -0
- package/ios/NativeListTitleSegmentsLabel.swift +92 -0
- package/ios/RNCNativeListView.swift +203 -45
- package/ios/tests/NativeListActivityPresentationTests.swift +137 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +155 -0
- package/ios/tests/NativeListLifecycleTests.swift +298 -24
- package/ios/tests/NativeListMediaVisibilityTests.swift +2 -1
- package/lib/module/models.js +2 -0
- package/lib/module/validation.js +96 -13
- package/lib/module/web/NativeListWebEngine.js +427 -100
- package/lib/module/web/templates/ActivityRowRenderer.js +1 -1
- package/lib/module/web/templates/IdentityRowRenderer.js +134 -3
- package/lib/module/web/templates/MarketRowRenderer.js +2 -0
- package/lib/module/web/templates/MediaTileRowRenderer.js +1 -0
- package/lib/module/web/templates/RowElements.js +2 -2
- package/lib/module/web/templates/RowText.js +2 -0
- package/lib/typescript/src/models.d.ts +35 -1
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +17 -2
- package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +6 -2
- package/lib/typescript/src/web/templates/RowVisual.d.ts +1 -1
- package/package.json +1 -1
- package/src/models.ts +38 -0
- package/src/validation.ts +196 -6
- package/src/web/NativeListWebEngine.ts +671 -112
- package/src/web/templates/ActivityRowRenderer.ts +1 -1
- package/src/web/templates/IdentityRowRenderer.ts +208 -3
- package/src/web/templates/MarketRowRenderer.ts +2 -0
- package/src/web/templates/MediaTileRowRenderer.ts +1 -0
- package/src/web/templates/RowElements.ts +3 -2
- package/src/web/templates/RowText.ts +6 -0
- package/src/web/templates/RowVisual.ts +2 -1
|
@@ -78,4 +78,159 @@ final class NativeListIdentityTitleIconLayoutTests: XCTestCase {
|
|
|
78
78
|
XCTAssertGreaterThan(badgeFrame.minX, iconFrame.maxX)
|
|
79
79
|
XCTAssertLessThanOrEqual(badgeFrame.maxX, cell.bounds.width)
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
// An address book row: a plain title after the 16pt `titleLeadingIcon`. A
|
|
83
|
+
// long name truncates after the glyph instead of squeezing it to nothing.
|
|
84
|
+
func testLongPlainTitleTruncatesAfterTheLeadingIcon() throws {
|
|
85
|
+
let cell = NativeListIdentityCell(frame: CGRect(x: 0, y: 0, width: 320, height: 60))
|
|
86
|
+
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 200))
|
|
87
|
+
window.addSubview(cell)
|
|
88
|
+
let leadingIcon = try child(cell, "titleLeadingIconView", as: UIImageView.self)
|
|
89
|
+
let titleLabel = try child(cell, "titleLabel", as: UILabel.self)
|
|
90
|
+
let item = try NativeListItem(data: [
|
|
91
|
+
"key": "book", "type": "identity",
|
|
92
|
+
"title": "A very long address book name that cannot possibly fit on one line",
|
|
93
|
+
"height": 60,
|
|
94
|
+
"leading": ["kind": "token", "fallbackIcon": ["name": "CryptoCoinOutline"]],
|
|
95
|
+
"titleLeadingIcon": ["name": "BookOpenOutline"],
|
|
96
|
+
"subtitle": "0x1234...abcd",
|
|
97
|
+
])
|
|
98
|
+
cell.bind(item: item, theme: nil, layout: "linear", selected: false,
|
|
99
|
+
checkboxState: { _, _, fallback in fallback }, fonts: NativeListFontFamilies())
|
|
100
|
+
cell.layoutIfNeeded()
|
|
101
|
+
|
|
102
|
+
let iconFrame = leadingIcon.convert(leadingIcon.bounds, to: cell)
|
|
103
|
+
let labelFrame = titleLabel.convert(titleLabel.bounds, to: cell)
|
|
104
|
+
XCTAssertFalse(leadingIcon.isHidden)
|
|
105
|
+
XCTAssertEqual(leadingIcon.bounds.width, 16, accuracy: 0.5,
|
|
106
|
+
"the leading glyph keeps its 16pt width")
|
|
107
|
+
XCTAssertEqual(labelFrame.minX, iconFrame.maxX + 6, accuracy: 1,
|
|
108
|
+
"the title follows the glyph with the 6pt gap")
|
|
109
|
+
XCTAssertLessThan(titleLabel.bounds.width, titleLabel.intrinsicContentSize.width,
|
|
110
|
+
"the title truncates instead of the glyph")
|
|
111
|
+
XCTAssertLessThanOrEqual(labelFrame.maxX, cell.bounds.width)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// A wallet sidebar row keeps the plain title even when a production row
|
|
115
|
+
// carries runs and a leading glyph, also after the cell drew both for a
|
|
116
|
+
// recipient row.
|
|
117
|
+
func testWalletSidebarRowIgnoresTitleRunsAndLeadingIcon() throws {
|
|
118
|
+
let cell = NativeListIdentityCell(frame: CGRect(x: 0, y: 0, width: 320, height: 68))
|
|
119
|
+
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 200))
|
|
120
|
+
window.addSubview(cell)
|
|
121
|
+
let titleLabel = try child(cell, "titleLabel", as: UILabel.self)
|
|
122
|
+
let runs = try child(cell, "titleSegmentsLabel", as: UIView.self)
|
|
123
|
+
let leadingIcon = try child(cell, "titleLeadingIconView", as: UIImageView.self)
|
|
124
|
+
let decorations: [String: Any] = [
|
|
125
|
+
"titleSegments": [
|
|
126
|
+
["text": "Main", "shrink": true],
|
|
127
|
+
["text": " / ", "tone": "secondary"],
|
|
128
|
+
["text": "Account 1"],
|
|
129
|
+
],
|
|
130
|
+
"titleLeadingIcon": ["name": "BookOpenOutline"],
|
|
131
|
+
]
|
|
132
|
+
func bind(_ data: [String: Any]) throws {
|
|
133
|
+
var row: [String: Any] = [
|
|
134
|
+
"key": "wallet", "type": "identity", "title": "Main / Account 1", "height": 68,
|
|
135
|
+
]
|
|
136
|
+
data.forEach { row[$0.key] = $0.value }
|
|
137
|
+
cell.bind(item: try NativeListItem(data: row), theme: nil, layout: "linear",
|
|
138
|
+
selected: false, checkboxState: { _, _, fallback in fallback },
|
|
139
|
+
fonts: NativeListFontFamilies())
|
|
140
|
+
cell.layoutIfNeeded()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
try bind(decorations)
|
|
144
|
+
XCTAssertFalse(runs.isHidden)
|
|
145
|
+
XCTAssertFalse(leadingIcon.isHidden)
|
|
146
|
+
|
|
147
|
+
try bind(decorations.merging(["presentation": "walletSidebar"]) { $1 })
|
|
148
|
+
XCTAssertTrue(runs.isHidden, "wallet sidebar rows draw no runs")
|
|
149
|
+
XCTAssertTrue(leadingIcon.isHidden, "wallet sidebar rows draw no leading glyph")
|
|
150
|
+
XCTAssertFalse(titleLabel.isHidden)
|
|
151
|
+
XCTAssertEqual(titleLabel.text, "Main / Account 1")
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// `titleMatch` keeps the plain highlighted title on screen, so an
|
|
155
|
+
// auto-height row is measured for that title and its `titleLines`, not for
|
|
156
|
+
// one line of runs.
|
|
157
|
+
func testHighlightedTitleIsMeasuredWithItsOwnLines() throws {
|
|
158
|
+
func height(_ data: [String: Any]) throws -> CGFloat {
|
|
159
|
+
var row: [String: Any] = [
|
|
160
|
+
"key": "match", "type": "identity", "contentHeight": "auto",
|
|
161
|
+
"title": "A very long recipient name that needs a second line to show",
|
|
162
|
+
"titleLines": 2, "titleMatch": [["start": 0, "end": 6]],
|
|
163
|
+
"subtitle": "0x1234...abcd",
|
|
164
|
+
]
|
|
165
|
+
data.forEach { row[$0.key] = $0.value }
|
|
166
|
+
return try XCTUnwrap(NativeListIdentityCell.measure(
|
|
167
|
+
try NativeListItem(data: row), width: 240, theme: nil, layout: "linear",
|
|
168
|
+
fonts: NativeListFontFamilies()))
|
|
169
|
+
}
|
|
170
|
+
let runs: [[String: Any]] = [["text": "A very long", "shrink": true], ["text": " recipient"]]
|
|
171
|
+
|
|
172
|
+
let plain = try height([:])
|
|
173
|
+
XCTAssertEqual(try height(["titleSegments": runs]), plain, accuracy: 0.5)
|
|
174
|
+
XCTAssertGreaterThan(plain, try height(["titleLines": 1]))
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private func autoHeight(_ data: [String: Any], width: CGFloat) throws -> CGFloat {
|
|
178
|
+
var row: [String: Any] = [
|
|
179
|
+
"key": "auto", "type": "identity", "contentHeight": "auto",
|
|
180
|
+
"title": "A very long recipient name that needs more than one line to show in full",
|
|
181
|
+
"titleLines": 3, "subtitle": "0x1234...abcd",
|
|
182
|
+
]
|
|
183
|
+
data.forEach { row[$0.key] = $0.value }
|
|
184
|
+
return try XCTUnwrap(NativeListIdentityCell.measure(
|
|
185
|
+
try NativeListItem(data: row), width: width, theme: nil, layout: "linear",
|
|
186
|
+
fonts: NativeListFontFamilies()))
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// The leading glyph and its gap take 22 points from the title, so the row
|
|
190
|
+
// measures like a plain row that much narrower, at every wrapping boundary.
|
|
191
|
+
func testAutoHeightCountsTheLeadingIconInTheTitleWidth() throws {
|
|
192
|
+
let icon: [String: Any] = ["name": "BookOpenOutline"]
|
|
193
|
+
for width in stride(from: CGFloat(200), through: 320, by: 6) {
|
|
194
|
+
XCTAssertEqual(
|
|
195
|
+
try autoHeight(["titleLeadingIcon": icon], width: width),
|
|
196
|
+
try autoHeight([:], width: width - 22), accuracy: 0.5, "width \(width)")
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Runs are one line, so `style.title.lines` must not reserve more for them.
|
|
201
|
+
func testRunsAreMeasuredAsOneLineWhateverTheTitleStyleAsksFor() throws {
|
|
202
|
+
let runs: [[String: Any]] = [["text": "A very long", "shrink": true], ["text": " recipient"]]
|
|
203
|
+
let twoLines: [String: Any] = ["title": ["lines": 2]]
|
|
204
|
+
|
|
205
|
+
let oneLine = try autoHeight(["titleSegments": runs, "titleLines": 1], width: 240)
|
|
206
|
+
XCTAssertEqual(
|
|
207
|
+
try autoHeight(["titleSegments": runs, "style": twoLines], width: 240), oneLine, accuracy: 0.5)
|
|
208
|
+
XCTAssertGreaterThan(try autoHeight(["style": twoLines], width: 240), oneLine)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// `style.title.offsetY` moves the runs as it moves a plain title, and a
|
|
212
|
+
// later row without it starts from zero again.
|
|
213
|
+
func testRunsTakeTheTitleOpticalOffset() throws {
|
|
214
|
+
let cell = NativeListIdentityCell(frame: CGRect(x: 0, y: 0, width: 320, height: 60))
|
|
215
|
+
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 200))
|
|
216
|
+
window.addSubview(cell)
|
|
217
|
+
let runsLabel = try child(cell, "titleSegmentsLabel", as: NativeListTitleSegmentsLabel.self)
|
|
218
|
+
func bind(_ style: [String: Any]?) throws {
|
|
219
|
+
var row: [String: Any] = [
|
|
220
|
+
"key": "runs", "type": "identity", "title": "Wallet / Account", "height": 60,
|
|
221
|
+
"titleSegments": [["text": "Wallet", "shrink": true], ["text": " / Account"]],
|
|
222
|
+
]
|
|
223
|
+
if let style { row["style"] = style }
|
|
224
|
+
cell.bind(item: try NativeListItem(data: row), theme: nil, layout: "linear", selected: false,
|
|
225
|
+
checkboxState: { _, _, fallback in fallback }, fonts: NativeListFontFamilies())
|
|
226
|
+
cell.layoutIfNeeded()
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
try bind(["title": ["offsetY": 3]])
|
|
230
|
+
XCTAssertFalse(runsLabel.isHidden)
|
|
231
|
+
XCTAssertEqual(runsLabel.offsetY, 3, accuracy: 0.01)
|
|
232
|
+
|
|
233
|
+
try bind(nil)
|
|
234
|
+
XCTAssertEqual(runsLabel.offsetY, 0, accuracy: 0.01)
|
|
235
|
+
}
|
|
81
236
|
}
|
|
@@ -1,9 +1,97 @@
|
|
|
1
|
+
import ObjectiveC
|
|
1
2
|
import UIKit
|
|
2
3
|
import XCTest
|
|
3
4
|
@testable import NativeListModule
|
|
4
5
|
|
|
5
6
|
@MainActor
|
|
6
7
|
final class NativeListLifecycleTests: XCTestCase {
|
|
8
|
+
func testFilteredSnapshotSuppliesCellsDuringOutgoingUIKitLayout() throws {
|
|
9
|
+
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 390, height: 697))
|
|
10
|
+
let window = UIWindow(frame: view.frame)
|
|
11
|
+
let controller = UIViewController()
|
|
12
|
+
window.rootViewController = controller
|
|
13
|
+
window.makeKeyAndVisible()
|
|
14
|
+
controller.view.addSubview(view)
|
|
15
|
+
defer {
|
|
16
|
+
view.dispose()
|
|
17
|
+
window.isHidden = true
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let collection = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
21
|
+
let dataSource = try XCTUnwrap(collection.dataSource as? UICollectionViewDiffableDataSource<Int, String>)
|
|
22
|
+
collection.isPrefetchingEnabled = false
|
|
23
|
+
collection.contentInsetAdjustmentBehavior = .never
|
|
24
|
+
collection.contentInset = UIEdgeInsets(top: 190, left: 0, bottom: 449, right: 0)
|
|
25
|
+
func snapshot(_ indices: Range<Int>) throws -> String {
|
|
26
|
+
let rows: [[String: Any]] = indices.map { index in
|
|
27
|
+
["key": "account-\(index)", "type": "identity", "title": "Account \(index)",
|
|
28
|
+
"testID": "recipient-\(index)", "height": 64,
|
|
29
|
+
"leading": ["kind": "icon", "name": "Circle"]]
|
|
30
|
+
}
|
|
31
|
+
let value: [String: Any] = ["schemaVersion": 1, "generation": 1,
|
|
32
|
+
"layout": ["kind": "linear"], "rows": rows]
|
|
33
|
+
return String(decoding: try JSONSerialization.data(withJSONObject: value), as: UTF8.self)
|
|
34
|
+
}
|
|
35
|
+
view.applySnapshotJson(try snapshot(0..<18))
|
|
36
|
+
view.layoutIfNeeded()
|
|
37
|
+
let initialOffset = CGPoint(x: 0, y: -190)
|
|
38
|
+
collection.contentOffset = initialOffset
|
|
39
|
+
collection.layoutIfNeeded()
|
|
40
|
+
XCTAssertEqual(dataSource.snapshot().numberOfItems, 18)
|
|
41
|
+
let outgoingIndexPath = IndexPath(item: 8, section: 0)
|
|
42
|
+
let outgoingFrame = try XCTUnwrap(collection.layoutAttributesForItem(at: outgoingIndexPath)).frame
|
|
43
|
+
XCTAssertFalse(collection.bounds.intersects(outgoingFrame))
|
|
44
|
+
XCTAssertNil(collection.cellForItem(at: outgoingIndexPath))
|
|
45
|
+
|
|
46
|
+
// Force a real UIKit layout at the invalidation inside applySnapshotJson,
|
|
47
|
+
// while UIKit still owns the old snapshot. Scope the hook to this layout.
|
|
48
|
+
let layout = collection.collectionViewLayout
|
|
49
|
+
let layoutClass: AnyClass = type(of: layout)
|
|
50
|
+
let selector = NSSelectorFromString("invalidateLayout")
|
|
51
|
+
let method = try XCTUnwrap(class_getInstanceMethod(layoutClass, selector))
|
|
52
|
+
let encoding = try XCTUnwrap(method_getTypeEncoding(method))
|
|
53
|
+
let original = method_getImplementation(method)
|
|
54
|
+
let callOriginal = unsafeBitCast(original, to: (@convention(c) (AnyObject, Selector) -> Void).self)
|
|
55
|
+
var didLayoutOutgoingSnapshot = false
|
|
56
|
+
let invalidate: @convention(block) (UICollectionViewLayout) -> Void = { current in
|
|
57
|
+
callOriginal(current, selector)
|
|
58
|
+
guard current === layout, !didLayoutOutgoingSnapshot,
|
|
59
|
+
dataSource.snapshot().numberOfItems == 18 else { return }
|
|
60
|
+
didLayoutOutgoingSnapshot = true
|
|
61
|
+
let size = view.collectionView(collection, layout: current, sizeForItemAt: outgoingIndexPath)
|
|
62
|
+
XCTAssertEqual(size.height, 64, "UIKit still needs the outgoing row’s geometry")
|
|
63
|
+
XCTAssertNil(collection.cellForItem(at: outgoingIndexPath))
|
|
64
|
+
collection.contentOffset.y = outgoingFrame.midY - collection.bounds.height / 2
|
|
65
|
+
collection.setNeedsLayout()
|
|
66
|
+
collection.layoutIfNeeded()
|
|
67
|
+
XCTAssertTrue(collection.bounds.intersects(outgoingFrame))
|
|
68
|
+
guard let outgoingCell = collection.cellForItem(at: outgoingIndexPath) else {
|
|
69
|
+
XCTFail("UIKit must request the previously offscreen outgoing cell")
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
XCTAssertEqual(outgoingCell.reuseIdentifier,
|
|
73
|
+
NativeListRendererRegistry.reuseIdentifier(for: .identity))
|
|
74
|
+
XCTAssertFalse(outgoingCell.isUserInteractionEnabled)
|
|
75
|
+
XCTAssertTrue(outgoingCell.accessibilityElementsHidden)
|
|
76
|
+
XCTAssertFalse(view.collectionView(collection, shouldSelectItemAt: outgoingIndexPath))
|
|
77
|
+
}
|
|
78
|
+
let replacement = imp_implementationWithBlock(invalidate)
|
|
79
|
+
class_replaceMethod(layoutClass, selector, replacement, encoding)
|
|
80
|
+
defer {
|
|
81
|
+
class_replaceMethod(layoutClass, selector, original, encoding)
|
|
82
|
+
imp_removeBlock(replacement)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
view.applySnapshotJson(try snapshot(12..<15))
|
|
86
|
+
collection.contentOffset = initialOffset
|
|
87
|
+
collection.layoutIfNeeded()
|
|
88
|
+
XCTAssertTrue(didLayoutOutgoingSnapshot)
|
|
89
|
+
XCTAssertEqual(dataSource.snapshot().itemIdentifiers, ["account-12", "account-13", "account-14"])
|
|
90
|
+
let first = try XCTUnwrap(collection.cellForItem(at: IndexPath(item: 0, section: 0)))
|
|
91
|
+
XCTAssertFalse(first.isHidden)
|
|
92
|
+
XCTAssertEqual(first.accessibilityIdentifier, "recipient-12")
|
|
93
|
+
}
|
|
94
|
+
|
|
7
95
|
func testCanonicalNullPatchRemovesStoredOptionalFields() throws {
|
|
8
96
|
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
|
|
9
97
|
let row: [String: Any] = ["key": "token", "type": "identity", "title": "Token",
|
|
@@ -135,11 +223,17 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
135
223
|
window.rootViewController = controller
|
|
136
224
|
controller.view.addSubview(view)
|
|
137
225
|
window.isHidden = false
|
|
138
|
-
defer { window.isHidden = true }
|
|
139
226
|
window.layoutIfNeeded()
|
|
140
227
|
view.layoutIfNeeded()
|
|
141
228
|
drainMainQueue()
|
|
142
229
|
let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
230
|
+
defer {
|
|
231
|
+
list.setContentOffset(list.contentOffset, animated: false)
|
|
232
|
+
view.dispose()
|
|
233
|
+
view.removeFromSuperview()
|
|
234
|
+
window.isHidden = true
|
|
235
|
+
window.rootViewController = nil
|
|
236
|
+
}
|
|
143
237
|
XCTAssertNotNil(view.window)
|
|
144
238
|
XCTAssertGreaterThan(list.contentSize.height - list.bounds.height +
|
|
145
239
|
list.adjustedContentInset.top + list.adjustedContentInset.bottom, 800)
|
|
@@ -1047,6 +1141,173 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1047
1141
|
XCTAssertTrue(second.isHidden)
|
|
1048
1142
|
}
|
|
1049
1143
|
|
|
1144
|
+
func testFixedFooterSharesRetiringRowKeyDuringStructuralTransition() throws {
|
|
1145
|
+
try requireStructuralAnimation()
|
|
1146
|
+
let footerData: [String: Any] = [
|
|
1147
|
+
"key": "a", "type": "action", "title": "Continue", "actionKey": "continue",
|
|
1148
|
+
]
|
|
1149
|
+
func snapshot(_ keys: [String], animate: Bool) throws -> String {
|
|
1150
|
+
let rows: [[String: Any]] = keys.map {
|
|
1151
|
+
["key": $0, "type": "action", "title": $0, "actionKey": "row-\($0)"]
|
|
1152
|
+
}
|
|
1153
|
+
var value: [String: Any] = ["schemaVersion": 1, "generation": animate ? 2 : 1,
|
|
1154
|
+
"layout": ["kind": "linear"], "rows": rows, "fixedFooter": footerData]
|
|
1155
|
+
if animate { value["structuralTransition"] = ["id": "remove-a", "durationMs": 800] }
|
|
1156
|
+
return String(decoding: try JSONSerialization.data(withJSONObject: value), as: UTF8.self)
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
|
|
1160
|
+
let controller = UIViewController()
|
|
1161
|
+
window.rootViewController = controller
|
|
1162
|
+
let view = NativeListView(frame: window.bounds)
|
|
1163
|
+
controller.view.addSubview(view)
|
|
1164
|
+
window.isHidden = false
|
|
1165
|
+
defer {
|
|
1166
|
+
view.dispose()
|
|
1167
|
+
window.isHidden = true
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
let collection = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
1171
|
+
let dataSource = try XCTUnwrap(collection.dataSource as? UICollectionViewDiffableDataSource<Int, String>)
|
|
1172
|
+
var actions: [String] = []
|
|
1173
|
+
view.onRowAction = { payload in
|
|
1174
|
+
if let action = (try? JSONSerialization.jsonObject(with: Data(payload.utf8))) as? [String: Any],
|
|
1175
|
+
let key = action["actionKey"] as? String { actions.append(key) }
|
|
1176
|
+
}
|
|
1177
|
+
view.applySnapshotJson(try snapshot(["a", "b", "c"], animate: false))
|
|
1178
|
+
view.layoutIfNeeded()
|
|
1179
|
+
collection.layoutIfNeeded()
|
|
1180
|
+
let outgoingIndex = IndexPath(item: 0, section: 0)
|
|
1181
|
+
let outgoing = try XCTUnwrap(collection.cellForItem(at: outgoingIndex) as? NativeListRowHost)
|
|
1182
|
+
let outgoingAction = try XCTUnwrap(outgoing.onAction)
|
|
1183
|
+
|
|
1184
|
+
view.applySnapshotJson(try snapshot(["b", "c"], animate: true))
|
|
1185
|
+
XCTAssertEqual(dataSource.itemIdentifier(for: outgoingIndex), "a")
|
|
1186
|
+
XCTAssertFalse(view.collectionView(collection, shouldSelectItemAt: outgoingIndex))
|
|
1187
|
+
view.collectionView(collection, didSelectItemAt: outgoingIndex)
|
|
1188
|
+
// Child renderers can emit a different key than the enclosing collection row.
|
|
1189
|
+
let child = try NativeListItem(data: ["key": "child", "type": "action", "title": "Child"])
|
|
1190
|
+
outgoingAction(child, "child-press", nil, outgoing.rowActionOrigin())
|
|
1191
|
+
XCTAssertTrue(actions.isEmpty)
|
|
1192
|
+
|
|
1193
|
+
let footer = try XCTUnwrap(footerCell(in: view))
|
|
1194
|
+
XCTAssertEqual(footer.accessibilityLabel, "Continue")
|
|
1195
|
+
XCTAssertEqual(footer.alpha, 1)
|
|
1196
|
+
XCTAssertTrue(footer.isUserInteractionEnabled)
|
|
1197
|
+
XCTAssertFalse(footer.accessibilityElementsHidden)
|
|
1198
|
+
// Dispatch the gesture's target directly in this hostless XCTest.
|
|
1199
|
+
let footerPress = NSSelectorFromString("footerPressed")
|
|
1200
|
+
XCTAssertTrue(view.responds(to: footerPress))
|
|
1201
|
+
_ = view.perform(footerPress)
|
|
1202
|
+
footer.onAction?(try NativeListItem(data: footerData), "footer-accessory", nil, footer.rowActionOrigin())
|
|
1203
|
+
XCTAssertEqual(actions, ["continue", "footer-accessory"])
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
func testPendingHandleReorderSurvivesSelectionEchoButRejectsHandleRemoval() throws {
|
|
1207
|
+
final class HandleTouch: UITouch {
|
|
1208
|
+
let handle: UIView
|
|
1209
|
+
init(handle: UIView) {
|
|
1210
|
+
self.handle = handle
|
|
1211
|
+
super.init()
|
|
1212
|
+
}
|
|
1213
|
+
override var view: UIView? { handle }
|
|
1214
|
+
override func location(in view: UIView?) -> CGPoint {
|
|
1215
|
+
handle.convert(CGPoint(x: handle.bounds.midX, y: handle.bounds.midY), to: view)
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
func findHandle(in view: UIView) -> NativeListAccessoryButton? {
|
|
1219
|
+
if let button = view as? NativeListAccessoryButton, button.isReorderHandle { return button }
|
|
1220
|
+
return view.subviews.lazy.compactMap { findHandle(in: $0) }.first
|
|
1221
|
+
}
|
|
1222
|
+
func snapshot(selected: Bool) throws -> String {
|
|
1223
|
+
let row: [String: Any] = [
|
|
1224
|
+
"type": "identity", "key": "source", "title": "Source", "height": 60,
|
|
1225
|
+
"selected": selected, "draggable": true, "trailing": [["kind": "drag"]],
|
|
1226
|
+
]
|
|
1227
|
+
let body: [String: Any] = [
|
|
1228
|
+
"schemaVersion": 1, "generation": 1, "layout": ["kind": "linear"],
|
|
1229
|
+
"capabilities": ["reorderable": true, "reorderActivation": "handle"],
|
|
1230
|
+
"selection": ["mode": "multiple", "selectedKeys": selected ? ["source"] : []],
|
|
1231
|
+
"rows": [row],
|
|
1232
|
+
]
|
|
1233
|
+
return String(decoding: try JSONSerialization.data(withJSONObject: body), as: UTF8.self)
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 390, height: 697))
|
|
1237
|
+
let controller = UIViewController()
|
|
1238
|
+
window.rootViewController = controller
|
|
1239
|
+
window.makeKeyAndVisible()
|
|
1240
|
+
let list = NativeListView(frame: window.bounds)
|
|
1241
|
+
controller.view.addSubview(list)
|
|
1242
|
+
defer {
|
|
1243
|
+
list.dispose()
|
|
1244
|
+
window.isHidden = true
|
|
1245
|
+
}
|
|
1246
|
+
list.applySnapshotJson(try snapshot(selected: false))
|
|
1247
|
+
window.layoutIfNeeded()
|
|
1248
|
+
list.layoutIfNeeded()
|
|
1249
|
+
let collection = try XCTUnwrap(list.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
1250
|
+
collection.layoutIfNeeded()
|
|
1251
|
+
let recognizer = try XCTUnwrap(collection.gestureRecognizers?.compactMap {
|
|
1252
|
+
$0 as? UILongPressGestureRecognizer
|
|
1253
|
+
}.first { String(describing: type(of: $0)) == "NativeListReorderLongPress" })
|
|
1254
|
+
let cell = try XCTUnwrap(collection.cellForItem(at: IndexPath(item: 0, section: 0)) as? NativeListRowHost)
|
|
1255
|
+
let handle = try XCTUnwrap(findHandle(in: cell))
|
|
1256
|
+
let epoch = cell.bindingEpoch
|
|
1257
|
+
XCTAssertTrue(list.gestureRecognizer(recognizer, shouldReceive: HandleTouch(handle: handle)))
|
|
1258
|
+
|
|
1259
|
+
list.applySnapshotJson(try snapshot(selected: true))
|
|
1260
|
+
XCTAssertEqual(cell.bindingEpoch, epoch)
|
|
1261
|
+
XCTAssertTrue(list.gestureRecognizerShouldBegin(recognizer))
|
|
1262
|
+
|
|
1263
|
+
list.applyPatchesJson(#"[{"type":"identity","key":"source","changes":{"trailing":[]}}]"#)
|
|
1264
|
+
XCTAssertFalse(list.gestureRecognizerShouldBegin(recognizer))
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
func testResolvedTrackingAffectsWidthAndIsClearedOnRebind() {
|
|
1268
|
+
let fonts = NativeListFontFamilies()
|
|
1269
|
+
func text(_ style: [String: Any]?) -> NativeListResolvedText {
|
|
1270
|
+
NativeListResolvedText("Wallet 123456", style: style, size: 16, color: .label,
|
|
1271
|
+
lineHeight: 24, lines: 1, tabular: true, fonts: fonts)
|
|
1272
|
+
}
|
|
1273
|
+
let label = NativeListTextLabel()
|
|
1274
|
+
let tracked = text(["letterSpacing": 4, "tabularNumbers": false])
|
|
1275
|
+
let standard = text(nil)
|
|
1276
|
+
tracked.bind(label)
|
|
1277
|
+
XCTAssertEqual(label.attributedText?.attribute(.kern, at: 0, effectiveRange: nil) as? CGFloat, 4)
|
|
1278
|
+
XCTAssertEqual(tracked.digitSpacing, false)
|
|
1279
|
+
XCTAssertGreaterThan(tracked.measureWidth(), standard.measureWidth())
|
|
1280
|
+
standard.bind(label)
|
|
1281
|
+
XCTAssertNil(label.attributedText?.attribute(.kern, at: 0, effectiveRange: nil))
|
|
1282
|
+
XCTAssertEqual(standard.digitSpacing, true)
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
func testAutoHeightIdentityAccountsForCollapsedTrailingAndTracking() throws {
|
|
1286
|
+
func item(collapse: Bool, tracking: Double) throws -> NativeListItem {
|
|
1287
|
+
try NativeListItem(data: [
|
|
1288
|
+
"key": "recipient", "type": "identity", "title": "Recipient",
|
|
1289
|
+
"subtitle": String(repeating: "Wallet 1234567890 ", count: 8),
|
|
1290
|
+
"subtitleLines": 0, "contentHeight": "auto",
|
|
1291
|
+
"collapseEmptyTrailing": collapse,
|
|
1292
|
+
"style": ["subtitle": ["letterSpacing": tracking]],
|
|
1293
|
+
])
|
|
1294
|
+
}
|
|
1295
|
+
func height(_ item: NativeListItem, width: CGFloat) throws -> CGFloat {
|
|
1296
|
+
try XCTUnwrap(NativeListIdentityCell.measure(
|
|
1297
|
+
item, width: width, theme: nil, layout: "linear", fonts: NativeListFontFamilies()))
|
|
1298
|
+
}
|
|
1299
|
+
let collapsed = try item(collapse: true, tracking: 0)
|
|
1300
|
+
let reserved = try item(collapse: false, tracking: 0)
|
|
1301
|
+
let tracked = try item(collapse: true, tracking: 4)
|
|
1302
|
+
let widths = stride(from: CGFloat(180), through: 260, by: 4)
|
|
1303
|
+
let differences = try widths.map { width in
|
|
1304
|
+
(try height(collapsed, width: width), try height(reserved, width: width),
|
|
1305
|
+
try height(tracked, width: width))
|
|
1306
|
+
}
|
|
1307
|
+
XCTAssertTrue(differences.contains { collapsed, reserved, _ in collapsed < reserved })
|
|
1308
|
+
XCTAssertTrue(differences.contains { collapsed, _, tracked in collapsed < tracked })
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1050
1311
|
func testFontResolversMeasureBindResetAndKeepIndependentInstances() throws {
|
|
1051
1312
|
let first = NativeListFontFamilies(names: ["regular": "Courier", "bold": "Courier-Bold"])
|
|
1052
1313
|
let second = NativeListFontFamilies(names: ["regular": "Georgia", "bold": "Georgia-Bold"])
|
|
@@ -1620,7 +1881,7 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1620
1881
|
view.layoutIfNeeded()
|
|
1621
1882
|
list.layoutIfNeeded()
|
|
1622
1883
|
} completion: { _ in finished.fulfill() }
|
|
1623
|
-
wait(for: [finished], timeout:
|
|
1884
|
+
wait(for: [finished], timeout: 5)
|
|
1624
1885
|
try check(phase, count: count, width: 700)
|
|
1625
1886
|
waitForStructuralFrames(0.1)
|
|
1626
1887
|
try check("\(phase) stable", count: count, width: 700)
|
|
@@ -1677,9 +1938,12 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1677
1938
|
XCTAssertEqual(list.contentOffset.y, testCase.offset, accuracy: 1, testCase.name)
|
|
1678
1939
|
|
|
1679
1940
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 25, transitionID: testCase.name))
|
|
1680
|
-
let
|
|
1681
|
-
|
|
1682
|
-
|
|
1941
|
+
let settleDeadline = Date().addingTimeInterval(5)
|
|
1942
|
+
while Mirror(reflecting: view).descendant("structuralDisplayLink") as? CADisplayLink != nil,
|
|
1943
|
+
Date() < settleDeadline {
|
|
1944
|
+
RunLoop.main.run(until: Date().addingTimeInterval(0.01))
|
|
1945
|
+
}
|
|
1946
|
+
waitForStructuralFrames(0.05)
|
|
1683
1947
|
list.layoutIfNeeded()
|
|
1684
1948
|
XCTAssertEqual(list.adjustedContentInset, explicitInset, testCase.name)
|
|
1685
1949
|
XCTAssertEqual(list.contentSize.height, testCase.height, accuracy: 1, testCase.name)
|
|
@@ -1801,17 +2065,20 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1801
2065
|
list.contentOffset.y = 900
|
|
1802
2066
|
list.layoutIfNeeded()
|
|
1803
2067
|
|
|
2068
|
+
let flow = try XCTUnwrap(list.collectionViewLayout as? NativeListFlowLayout)
|
|
1804
2069
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 30, generation: 2,
|
|
1805
|
-
transitionID: "expand-first", durationMs:
|
|
1806
|
-
|
|
2070
|
+
transitionID: "expand-first", durationMs: 1200))
|
|
2071
|
+
let expandDeadline = Date().addingTimeInterval(3)
|
|
2072
|
+
while (flow.tailClip?.endY ?? 0) <= 1505 && Date() < expandDeadline {
|
|
2073
|
+
RunLoop.main.run(until: Date().addingTimeInterval(0.01))
|
|
2074
|
+
}
|
|
1807
2075
|
list.contentOffset.y = 1100
|
|
1808
2076
|
list.layoutIfNeeded()
|
|
1809
2077
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 25, generation: 3,
|
|
1810
|
-
transitionID: "collapse-middle", durationMs:
|
|
2078
|
+
transitionID: "collapse-middle", durationMs: 2400))
|
|
1811
2079
|
waitForStructuralFrames(0.08)
|
|
1812
2080
|
list.layoutIfNeeded()
|
|
1813
2081
|
let source = try XCTUnwrap(list.dataSource as? UICollectionViewDiffableDataSource<Int, String>)
|
|
1814
|
-
let flow = try XCTUnwrap(list.collectionViewLayout as? NativeListFlowLayout)
|
|
1815
2082
|
let clip = try XCTUnwrap(flow.tailClip)
|
|
1816
2083
|
let retiring = try XCTUnwrap(list.cellForItem(at: IndexPath(item: 25, section: 0)) as? NativeListRowHost)
|
|
1817
2084
|
XCTAssertGreaterThan(clip.endY, 1500)
|
|
@@ -2129,7 +2396,7 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2129
2396
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 6, generation: 5,
|
|
2130
2397
|
transitionID: "collapse-latest", durationMs: 400,
|
|
2131
2398
|
disclosureExpanded: false))
|
|
2132
|
-
wait(for: [latestSettled], timeout:
|
|
2399
|
+
wait(for: [latestSettled], timeout: 5)
|
|
2133
2400
|
XCTAssertEqual(settlements.map(\.0), ["same-rows", "collapse-latest"])
|
|
2134
2401
|
XCTAssertEqual(settlements.last?.1, "completed")
|
|
2135
2402
|
XCTAssertEqual(settlements.last?.2, false)
|
|
@@ -2321,13 +2588,13 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2321
2588
|
defer { growthProbe.invalidate() }
|
|
2322
2589
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 50, generation: 2,
|
|
2323
2590
|
transitionID: "grow", durationMs: 800, disclosureExpanded: true))
|
|
2324
|
-
wait(for: [growthPhase], timeout:
|
|
2591
|
+
wait(for: [growthPhase], timeout: 5)
|
|
2325
2592
|
guard growthObserved else {
|
|
2326
2593
|
XCTFail("No partial disclosure growth frame observed: \(growthLast)")
|
|
2327
2594
|
return
|
|
2328
2595
|
}
|
|
2329
2596
|
growthProbe.invalidate()
|
|
2330
|
-
wait(for: [growSettled], timeout:
|
|
2597
|
+
wait(for: [growSettled], timeout: 5)
|
|
2331
2598
|
XCTAssertEqual(contentHost.bounds.height, 140, accuracy: 1)
|
|
2332
2599
|
XCTAssertNil(contentHost.layer.mask)
|
|
2333
2600
|
XCTAssertTrue(contentHost.isUserInteractionEnabled)
|
|
@@ -2366,7 +2633,7 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2366
2633
|
defer { collapseProbe.invalidate() }
|
|
2367
2634
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 6, generation: 3,
|
|
2368
2635
|
transitionID: "drag", durationMs: 800, disclosureExpanded: false))
|
|
2369
|
-
wait(for: [collapsePhase], timeout:
|
|
2636
|
+
wait(for: [collapsePhase], timeout: 5)
|
|
2370
2637
|
guard collapseObserved else {
|
|
2371
2638
|
XCTFail("No partial disclosure collapse frame observed: \(collapseLast)")
|
|
2372
2639
|
return
|
|
@@ -2875,8 +3142,8 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2875
3142
|
drainMainQueue()
|
|
2876
3143
|
list.contentOffset.y = 300
|
|
2877
3144
|
list.layoutIfNeeded()
|
|
2878
|
-
view.applySnapshotJson(try structuralRowsSnapshot(count:
|
|
2879
|
-
transitionID: "interrupt-boundary", durationMs:
|
|
3145
|
+
view.applySnapshotJson(try structuralRowsSnapshot(count: 15, generation: 2,
|
|
3146
|
+
transitionID: "interrupt-boundary", durationMs: 2400))
|
|
2880
3147
|
let footerBottomBeforeResize = footer.convert(.zero, to: list).y + 60
|
|
2881
3148
|
view.setContainerSlotHeightsJson("[0,0,80,2200]")
|
|
2882
3149
|
XCTAssertEqual(footer.convert(.zero, to: list).y + 80,
|
|
@@ -2890,7 +3157,7 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2890
3157
|
XCTAssertFalse(footerHost.point(inside: CGPoint(x: 10, y: hiddenTop / 2), with: nil))
|
|
2891
3158
|
XCTAssertTrue(footerHost.point(inside: CGPoint(x: 10, y: hiddenTop + 1), with: nil))
|
|
2892
3159
|
var boundaryCell: NativeListRowHost?
|
|
2893
|
-
let deadline = Date().addingTimeInterval(
|
|
3160
|
+
let deadline = Date().addingTimeInterval(3)
|
|
2894
3161
|
while boundaryCell == nil && Date() < deadline {
|
|
2895
3162
|
if let clip = flow.tailClip {
|
|
2896
3163
|
for case let cell as NativeListRowHost in list.visibleCells {
|
|
@@ -3172,9 +3439,13 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
3172
3439
|
}
|
|
3173
3440
|
|
|
3174
3441
|
private func waitForStructuralFrames(_ seconds: TimeInterval) {
|
|
3175
|
-
let
|
|
3176
|
-
|
|
3177
|
-
|
|
3442
|
+
let deadline = Date().addingTimeInterval(seconds)
|
|
3443
|
+
while Date() < deadline {
|
|
3444
|
+
RunLoop.main.run(until: Date().addingTimeInterval(0.01))
|
|
3445
|
+
}
|
|
3446
|
+
for _ in 0..<4 {
|
|
3447
|
+
RunLoop.main.run(until: Date().addingTimeInterval(0.02))
|
|
3448
|
+
}
|
|
3178
3449
|
}
|
|
3179
3450
|
|
|
3180
3451
|
private func labels(in view: UIView) -> [UILabel] {
|
|
@@ -3343,14 +3614,17 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
3343
3614
|
}
|
|
3344
3615
|
|
|
3345
3616
|
private func drainMainQueue() {
|
|
3346
|
-
|
|
3347
|
-
DispatchQueue.main.async {
|
|
3348
|
-
|
|
3617
|
+
var drained = false
|
|
3618
|
+
DispatchQueue.main.async { drained = true }
|
|
3619
|
+
let deadline = Date().addingTimeInterval(5)
|
|
3620
|
+
while !drained && Date() < deadline {
|
|
3621
|
+
RunLoop.main.run(until: Date().addingTimeInterval(0.01))
|
|
3622
|
+
}
|
|
3349
3623
|
}
|
|
3350
3624
|
|
|
3351
3625
|
private func footerCell(in view: NativeListView) -> NativeListRowHost? {
|
|
3352
|
-
view.subviews.lazy.compactMap { container in
|
|
3353
|
-
container.subviews.
|
|
3626
|
+
view.subviews.lazy.filter { !($0 is UICollectionView) }.compactMap { container in
|
|
3627
|
+
container.subviews.first { $0 is NativeListRowHost } as? NativeListRowHost
|
|
3354
3628
|
}.first
|
|
3355
3629
|
}
|
|
3356
3630
|
}
|
|
@@ -58,6 +58,7 @@ final class NativeListMediaFrameCaptureTests: XCTestCase {
|
|
|
58
58
|
rootView.addSubview(container)
|
|
59
59
|
defer { container.removeFromSuperview() }
|
|
60
60
|
let slot = NativeListMediaPreviewSlot()
|
|
61
|
+
defer { slot.recycle() }
|
|
61
62
|
slot.view.frame = CGRect(x: 0, y: 0, width: 120, height: 120)
|
|
62
63
|
container.addSubview(slot.view)
|
|
63
64
|
slot.view.layoutIfNeeded()
|
|
@@ -98,6 +99,7 @@ final class NativeListMediaFrameCaptureTests: XCTestCase {
|
|
|
98
99
|
XCTAssertNotNil(slot.capturedFrame)
|
|
99
100
|
XCTAssertEqual(slot.createdPlayerCount, coldPlayers, "Recycled row reuses the cached still")
|
|
100
101
|
let second = NativeListMediaPreviewSlot()
|
|
102
|
+
defer { second.recycle() }
|
|
101
103
|
second.view.frame = CGRect(x: 120, y: 0, width: 120, height: 120)
|
|
102
104
|
container.addSubview(second.view)
|
|
103
105
|
second.view.layoutIfNeeded()
|
|
@@ -108,7 +110,6 @@ final class NativeListMediaFrameCaptureTests: XCTestCase {
|
|
|
108
110
|
}
|
|
109
111
|
XCTAssertNotNil(second.capturedFrame)
|
|
110
112
|
XCTAssertEqual(second.createdPlayerCount, 0, "A different cell uses shared cached pixels")
|
|
111
|
-
second.recycle(); slot.recycle()
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
/// A 64×48, ten-frame H.264 MP4 (generated with AVAssetWriter on macOS); the simulator
|
package/lib/module/models.js
CHANGED
|
@@ -39,6 +39,8 @@ export const ROW_BOX_STYLE_KEYS_BY_TYPE = {
|
|
|
39
39
|
|
|
40
40
|
// OneKey patch: preserve compact very-small-balance digit runs.
|
|
41
41
|
|
|
42
|
+
/** One run of an identity title line; see docs/SPEC.md. */
|
|
43
|
+
|
|
42
44
|
/** Native Market quote row. All values are already localized/formatted strings. */
|
|
43
45
|
|
|
44
46
|
/** Compact KPI card for dashboards and grids. */
|