@onekeyfe/react-native-native-list 6.7.0-alpha.466 → 6.8.0-2
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/README.md +312 -379
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +15 -6
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPlaceholderView.kt +244 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +60 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +5 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +75 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +25 -19
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListDescriptionTouchPolicyTest.kt +153 -0
- package/docs/ROW_TEMPLATES.md +8 -3
- package/docs/SPEC.md +258 -18
- package/docs/STYLE_SPEC.md +12 -0
- package/ios/NativeListActivityDetailsView.swift +13 -5
- package/ios/NativeListMediaPlaceholderView.swift +189 -0
- package/ios/NativeListMediaPreviewSlot.swift +122 -61
- package/ios/NativeListMediaTileRenderer.swift +13 -13
- package/ios/NativeListResolvedText.swift +15 -4
- package/ios/NativeListTextLabel.swift +106 -0
- package/ios/RNCNativeListView.swift +50 -7
- package/ios/tests/NativeListActivityPresentationTests.swift +270 -0
- package/ios/tests/NativeListLifecycleTests.swift +176 -16
- package/ios/tests/NativeListMediaVisibilityTests.swift +41 -7
- package/lib/module/NativeList.js +17 -4
- package/lib/module/NativeList.web.js +3 -1
- package/lib/module/validation.js +19 -2
- package/lib/module/web/NativeListWebEngine.js +13 -11
- package/lib/module/web/templates/ActivityRowRenderer.js +29 -23
- package/lib/module/web/templates/DataRowRenderer.js +16 -0
- package/lib/module/web/templates/IdentityRowRenderer.js +3 -1
- package/lib/module/web/templates/MediaTileRowRenderer.js +84 -15
- package/lib/typescript/src/models.d.ts +9 -1
- package/package.json +1 -1
- package/src/NativeList.tsx +25 -4
- package/src/NativeList.web.tsx +1 -1
- package/src/models.ts +9 -0
- package/src/validation.ts +34 -0
- package/src/web/NativeListWebEngine.ts +16 -11
- package/src/web/templates/ActivityRowRenderer.ts +42 -32
- package/src/web/templates/DataRowRenderer.ts +28 -0
- package/src/web/templates/IdentityRowRenderer.ts +3 -3
- package/src/web/templates/MediaTileRowRenderer.ts +90 -15
|
@@ -60,6 +60,276 @@ final class NativeListActivityPresentationTests: XCTestCase {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
// The description label spans the identity column, so a tap anywhere on its
|
|
64
|
+
// line used to open the description action. Only the action text opens it
|
|
65
|
+
// now; the blank rest of the line belongs to the row press (OK-67219). Where
|
|
66
|
+
// that text starts is the caller's `descriptionActionStart`, never something
|
|
67
|
+
// read out of the string.
|
|
68
|
+
func testDescriptionActionTakesTouchesOnItsTextOnly() throws {
|
|
69
|
+
let details = NativeListActivityDetailsView()
|
|
70
|
+
// Wide enough that the label keeps blank space beside its text even when
|
|
71
|
+
// the amounts take their full half of the row.
|
|
72
|
+
let container = UIView(frame: CGRect(x: 0, y: 0, width: 600, height: 300))
|
|
73
|
+
details.translatesAutoresizingMaskIntoConstraints = false
|
|
74
|
+
container.addSubview(details)
|
|
75
|
+
NSLayoutConstraint.activate([
|
|
76
|
+
details.leadingAnchor.constraint(equalTo: container.leadingAnchor),
|
|
77
|
+
details.trailingAnchor.constraint(equalTo: container.trailingAnchor),
|
|
78
|
+
details.topAnchor.constraint(equalTo: container.topAnchor),
|
|
79
|
+
])
|
|
80
|
+
func bind(description: String, actionKey: String?, actionStart: Int? = nil) throws -> NativeListTextLabel {
|
|
81
|
+
var data: [String: Any] = [
|
|
82
|
+
"type": "activity", "key": "tx", "title": "Swap", "description": description,
|
|
83
|
+
"leading": ["kind": "icon", "name": "ArrowTopOutline"],
|
|
84
|
+
"amounts": [["key": "send", "text": "-1"]],
|
|
85
|
+
]
|
|
86
|
+
if let actionKey { data["descriptionActionKey"] = actionKey }
|
|
87
|
+
if let actionStart { data["descriptionActionStart"] = actionStart }
|
|
88
|
+
details.bind(try NativeListItem(data: data), theme: nil, fonts: NativeListFontFamilies())
|
|
89
|
+
container.layoutIfNeeded()
|
|
90
|
+
func find(_ view: UIView) -> NativeListTextLabel? {
|
|
91
|
+
if let label = view as? NativeListTextLabel, label.text == description { return label }
|
|
92
|
+
return view.subviews.lazy.compactMap(find).first
|
|
93
|
+
}
|
|
94
|
+
return try XCTUnwrap(find(details))
|
|
95
|
+
}
|
|
96
|
+
func hit(_ label: NativeListTextLabel, x: CGFloat) -> Bool {
|
|
97
|
+
label.point(inside: CGPoint(x: x, y: label.bounds.midY), with: nil)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Without a start the whole text is the action, also a label holding the
|
|
101
|
+
// separator a time prefix would use.
|
|
102
|
+
let label = try bind(description: "Router • V2", actionKey: "address-info")
|
|
103
|
+
let labelText = try XCTUnwrap(label.touchableTextRegions.first)
|
|
104
|
+
XCTAssertEqual(label.touchableTextStart, 0)
|
|
105
|
+
XCTAssertEqual(label.touchableTextRegions.count, 1)
|
|
106
|
+
XCTAssertGreaterThan(label.bounds.width, labelText.maxX + 40)
|
|
107
|
+
XCTAssertTrue(hit(label, x: 4))
|
|
108
|
+
XCTAssertTrue(hit(label, x: labelText.maxX - 12))
|
|
109
|
+
XCTAssertFalse(hit(label, x: label.bounds.maxX - 4))
|
|
110
|
+
|
|
111
|
+
// With a start only the text from there on is the action: the time is
|
|
112
|
+
// not, the complete label behind it is.
|
|
113
|
+
let prefix = "08:48 • "
|
|
114
|
+
let timed = try bind(
|
|
115
|
+
description: prefix + "Router • V2", actionKey: "address-info",
|
|
116
|
+
actionStart: (prefix as NSString).length)
|
|
117
|
+
let timedText = try XCTUnwrap(timed.touchableTextRegions.first)
|
|
118
|
+
XCTAssertEqual(timed.touchableTextRegions.count, 1)
|
|
119
|
+
XCTAssertGreaterThan(timed.bounds.width, timedText.maxX + 40)
|
|
120
|
+
// The same label, less the slop on the side where the time is.
|
|
121
|
+
XCTAssertEqual(timedText.width, labelText.width - 8, accuracy: 1)
|
|
122
|
+
XCTAssertFalse(hit(timed, x: 4))
|
|
123
|
+
XCTAssertFalse(hit(timed, x: timedText.minX - 2))
|
|
124
|
+
XCTAssertTrue(hit(timed, x: timedText.minX + 2))
|
|
125
|
+
XCTAssertTrue(hit(timed, x: timedText.maxX - 12))
|
|
126
|
+
XCTAssertFalse(hit(timed, x: timed.bounds.maxX - 4))
|
|
127
|
+
|
|
128
|
+
// The start counts UTF-16 units: the emoji takes two.
|
|
129
|
+
let emojiPrefix = "🕘 08:48 • "
|
|
130
|
+
XCTAssertEqual((emojiPrefix as NSString).length, 11)
|
|
131
|
+
let emoji = try bind(
|
|
132
|
+
description: emojiPrefix + "Router • V2", actionKey: "address-info", actionStart: 11)
|
|
133
|
+
let emojiText = try XCTUnwrap(emoji.touchableTextRegions.first)
|
|
134
|
+
XCTAssertEqual(emojiText.width, labelText.width - 8, accuracy: 1)
|
|
135
|
+
XCTAssertFalse(hit(emoji, x: 4))
|
|
136
|
+
XCTAssertFalse(hit(emoji, x: emojiText.minX - 2))
|
|
137
|
+
XCTAssertTrue(hit(emoji, x: emojiText.minX + 2))
|
|
138
|
+
XCTAssertTrue(hit(emoji, x: emojiText.maxX - 12))
|
|
139
|
+
|
|
140
|
+
// A start at the end of the text, or clamped to it, leaves nothing to tap.
|
|
141
|
+
// 4294967296 is a safe integer past 32 bits; it must clamp, not wrap to 0.
|
|
142
|
+
for start in [(prefix as NSString).length, 99, 4_294_967_296] {
|
|
143
|
+
let ended = try bind(description: prefix, actionKey: "address-info", actionStart: start)
|
|
144
|
+
XCTAssertTrue(ended.touchableTextRegions.isEmpty)
|
|
145
|
+
XCTAssertFalse(ended.isUserInteractionEnabled)
|
|
146
|
+
XCTAssertFalse(hit(ended, x: 4))
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// The reused view keeps no state: a rebind without a start covers the
|
|
150
|
+
// whole text again, one without the action restores the label's own hit
|
|
151
|
+
// testing even when a start is still supplied, and so does recycling.
|
|
152
|
+
let rebound = try bind(description: "Router • V2", actionKey: "address-info")
|
|
153
|
+
XCTAssertEqual(rebound.touchableTextStart, 0)
|
|
154
|
+
XCTAssertTrue(rebound.isUserInteractionEnabled)
|
|
155
|
+
XCTAssertTrue(hit(rebound, x: 4))
|
|
156
|
+
let plain = try bind(description: "Router • V2", actionKey: nil, actionStart: 3)
|
|
157
|
+
XCTAssertNil(plain.touchableTextStart)
|
|
158
|
+
XCTAssertFalse(plain.isUserInteractionEnabled)
|
|
159
|
+
XCTAssertTrue(hit(plain, x: plain.bounds.maxX - 4))
|
|
160
|
+
let recycled = try bind(
|
|
161
|
+
description: prefix + "Router", actionKey: "address-info",
|
|
162
|
+
actionStart: (prefix as NSString).length)
|
|
163
|
+
XCTAssertEqual(recycled.touchableTextStart, (prefix as NSString).length)
|
|
164
|
+
details.recycle()
|
|
165
|
+
XCTAssertNil(recycled.touchableTextStart)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// A narrow column wraps "time • address". The time stays outside the action
|
|
169
|
+
// on its line, while the address is hit on both lines, also at the x the
|
|
170
|
+
// time occupies one line above. The label is sized directly so the wrap does
|
|
171
|
+
// not depend on how the row shares its width.
|
|
172
|
+
func testWrappedDescriptionKeepsTheTimeOutsideTheAction() throws {
|
|
173
|
+
let description = "08:48 • Uniswap Router"
|
|
174
|
+
let label = NativeListTextLabel()
|
|
175
|
+
NativeListResolvedText(
|
|
176
|
+
description, style: nil, size: 14, color: .label, lineHeight: 20, lines: 2,
|
|
177
|
+
fonts: NativeListFontFamilies()
|
|
178
|
+
).bind(label)
|
|
179
|
+
label.frame = CGRect(x: 0, y: 0, width: 142, height: 40)
|
|
180
|
+
label.touchableTextStart = ("08:48 • " as NSString).length
|
|
181
|
+
func hit(_ x: CGFloat, _ y: CGFloat) -> Bool {
|
|
182
|
+
label.point(inside: CGPoint(x: x, y: y), with: nil)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
let lines = label.touchableTextRegions
|
|
186
|
+
XCTAssertEqual(lines.count, 2)
|
|
187
|
+
guard lines.count == 2 else { return }
|
|
188
|
+
XCTAssertFalse(hit(4, lines[0].midY))
|
|
189
|
+
XCTAssertTrue(hit(lines[0].maxX - 12, lines[0].midY))
|
|
190
|
+
XCTAssertTrue(hit(4, lines[1].midY))
|
|
191
|
+
XCTAssertFalse(hit(label.bounds.maxX - 2, lines[1].midY))
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// The first line holds only the time, so it takes no touches, and the slop
|
|
195
|
+
// of the address line below it must not reach up into the time.
|
|
196
|
+
func testAddressStartingOnTheSecondLineLeavesTheTimeLineAlone() throws {
|
|
197
|
+
let prefix = "08:48 • "
|
|
198
|
+
let address = "UniswapUniversalRouter"
|
|
199
|
+
func text(_ value: String) -> NativeListResolvedText {
|
|
200
|
+
NativeListResolvedText(
|
|
201
|
+
value, style: nil, size: 14, color: .label, lineHeight: 20, lines: 2,
|
|
202
|
+
fonts: NativeListFontFamilies())
|
|
203
|
+
}
|
|
204
|
+
let label = NativeListTextLabel()
|
|
205
|
+
text(prefix + address).bind(label)
|
|
206
|
+
// Wide enough for the address alone, too narrow for the time beside it.
|
|
207
|
+
label.frame = CGRect(x: 0, y: 0, width: text(address).measureWidth() + 4, height: 40)
|
|
208
|
+
label.touchableTextStart = (prefix as NSString).length
|
|
209
|
+
func hit(y: CGFloat) -> Bool { label.point(inside: CGPoint(x: 4, y: y), with: nil) }
|
|
210
|
+
|
|
211
|
+
let line = try XCTUnwrap(label.touchableTextRegions.first)
|
|
212
|
+
XCTAssertEqual(label.touchableTextRegions.count, 1)
|
|
213
|
+
XCTAssertEqual(line.minY, 20, accuracy: 0.5)
|
|
214
|
+
XCTAssertFalse(hit(y: 10))
|
|
215
|
+
XCTAssertFalse(hit(y: line.minY - 2))
|
|
216
|
+
XCTAssertTrue(hit(y: line.minY + 2))
|
|
217
|
+
// The last line of the layout still takes its slop below the text.
|
|
218
|
+
XCTAssertTrue(hit(y: label.bounds.maxY + 4))
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private func descriptionText(_ value: String, style: [String: Any]? = nil) -> NativeListResolvedText {
|
|
222
|
+
NativeListResolvedText(
|
|
223
|
+
value, style: style, size: 14, color: .label, lineHeight: 20, lines: 1,
|
|
224
|
+
fonts: NativeListFontFamilies())
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/// Width the description font gives `value` on its own.
|
|
228
|
+
private func descriptionWidth(_ value: String) -> CGFloat {
|
|
229
|
+
descriptionText(value).attributed(direction: .leftToRight).size().width
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
private func descriptionLabel(
|
|
233
|
+
_ value: String, start: Int, width: CGFloat = 300, style: [String: Any]? = nil
|
|
234
|
+
) -> NativeListTextLabel {
|
|
235
|
+
let label = NativeListTextLabel()
|
|
236
|
+
descriptionText(value, style: style).bind(label)
|
|
237
|
+
label.frame = CGRect(x: 0, y: 0, width: width, height: 20)
|
|
238
|
+
label.touchableTextStart = start
|
|
239
|
+
return label
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
private func hit(_ label: NativeListTextLabel, x: CGFloat) -> Bool {
|
|
243
|
+
label.point(inside: CGPoint(x: x, y: label.bounds.midY), with: nil)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// The slop is for blank space. It stops at plain text beside the action
|
|
247
|
+
// text, or a prefix narrower than the slop, like the "i" of "iRouter", would
|
|
248
|
+
// open an action it is not part of.
|
|
249
|
+
func testSlopStopsAtPlainTextBesideTheActionText() throws {
|
|
250
|
+
let short = descriptionLabel("iRouter", start: 1)
|
|
251
|
+
let i = descriptionWidth("i")
|
|
252
|
+
XCTAssertLessThan(i, 8)
|
|
253
|
+
let region = try XCTUnwrap(short.touchableTextRegions.first)
|
|
254
|
+
XCTAssertEqual(short.touchableTextRegions.count, 1)
|
|
255
|
+
XCTAssertEqual(region.minX, i, accuracy: 0.5)
|
|
256
|
+
XCTAssertFalse(hit(short, x: i / 2))
|
|
257
|
+
XCTAssertFalse(hit(short, x: -3))
|
|
258
|
+
XCTAssertTrue(hit(short, x: i + 2))
|
|
259
|
+
// Into the blank after the text the slop still reaches.
|
|
260
|
+
XCTAssertTrue(hit(short, x: descriptionWidth("iRouter") + 6))
|
|
261
|
+
XCTAssertFalse(hit(short, x: descriptionWidth("iRouter") + 10))
|
|
262
|
+
// And into the blank before a line that starts with the action text.
|
|
263
|
+
XCTAssertTrue(hit(descriptionLabel("Router", start: 0), x: -6))
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Mixed-direction text can split one logical suffix into several visual
|
|
267
|
+
// runs. From offset 6 of "ABC אבג XYZ" the suffix is the last Hebrew letter
|
|
268
|
+
// and " XYZ"; the Hebrew run is drawn right to left, so that letter sits
|
|
269
|
+
// left of the two plain ones. Each run is its own region and the plain text
|
|
270
|
+
// between them takes no touches.
|
|
271
|
+
func testMixedDirectionSuffixFollowsTheLaidOutRuns() {
|
|
272
|
+
let label = descriptionLabel("ABC \u{05D0}\u{05D1}\u{05D2} XYZ", start: 6)
|
|
273
|
+
let abc = descriptionWidth("ABC ")
|
|
274
|
+
let last = descriptionWidth("\u{05D2}")
|
|
275
|
+
let plain = descriptionWidth("\u{05D1}\u{05D0}")
|
|
276
|
+
let xyz = descriptionWidth(" XYZ")
|
|
277
|
+
let regions = label.touchableTextRegions.sorted { $0.minX < $1.minX }
|
|
278
|
+
XCTAssertEqual(regions.count, 2)
|
|
279
|
+
guard regions.count == 2 else { return }
|
|
280
|
+
XCTAssertEqual(regions[0].minX, abc, accuracy: 1)
|
|
281
|
+
XCTAssertEqual(regions[0].maxX, abc + last, accuracy: 1)
|
|
282
|
+
XCTAssertEqual(regions[1].minX, abc + last + plain, accuracy: 1)
|
|
283
|
+
XCTAssertFalse(hit(label, x: abc / 2))
|
|
284
|
+
XCTAssertTrue(hit(label, x: abc + last / 2))
|
|
285
|
+
XCTAssertFalse(hit(label, x: abc + last + plain / 2))
|
|
286
|
+
XCTAssertTrue(hit(label, x: abc + last + plain + xyz / 2))
|
|
287
|
+
// Only the outer edge of the last run faces blank space.
|
|
288
|
+
XCTAssertTrue(hit(label, x: abc + last + plain + xyz + 5))
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// A one-line description that does not fit ends in an ellipsis. Action text
|
|
292
|
+
// it only shortens stays touchable up to and including the ellipsis. Once it
|
|
293
|
+
// hides the action text altogether the ellipsis also stands for plain text,
|
|
294
|
+
// and nothing is left to touch.
|
|
295
|
+
func testTruncationCanHideTheActionText() throws {
|
|
296
|
+
let cut = descriptionLabel(
|
|
297
|
+
"08:48 • UniswapUniversalRouterWithAVeryLongName", start: 8, width: 150,
|
|
298
|
+
style: ["lines": 1])
|
|
299
|
+
let region = try XCTUnwrap(cut.touchableTextRegions.first)
|
|
300
|
+
XCTAssertEqual(cut.touchableTextRegions.count, 1)
|
|
301
|
+
XCTAssertEqual(region.minX, descriptionWidth("08:48 • "), accuracy: 1)
|
|
302
|
+
XCTAssertFalse(hit(cut, x: 20))
|
|
303
|
+
XCTAssertTrue(hit(cut, x: 100))
|
|
304
|
+
XCTAssertTrue(hit(cut, x: 145))
|
|
305
|
+
|
|
306
|
+
let prefix = "A very long plain prefix that fills the row • "
|
|
307
|
+
let hidden = descriptionLabel(
|
|
308
|
+
prefix + "Router", start: (prefix as NSString).length, width: 150, style: ["lines": 1])
|
|
309
|
+
XCTAssertTrue(hidden.touchableTextRegions.isEmpty)
|
|
310
|
+
XCTAssertFalse(hit(hidden, x: 145))
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// A one-line description folds each line break into one space, so the
|
|
314
|
+
// caller's offset is mapped onto the displayed text and kept inside it.
|
|
315
|
+
func testDescriptionActionStartFollowsTheDisplayedText() {
|
|
316
|
+
let source = "08:48\r\n• Router"
|
|
317
|
+
func text(_ style: [String: Any]?) -> NativeListResolvedText {
|
|
318
|
+
NativeListResolvedText(
|
|
319
|
+
source, style: style, size: 14, color: .label, lineHeight: 20, lines: 2,
|
|
320
|
+
fonts: NativeListFontFamilies())
|
|
321
|
+
}
|
|
322
|
+
let oneLine = text(["lines": 1])
|
|
323
|
+
XCTAssertEqual(oneLine.text, "08:48 • Router")
|
|
324
|
+
XCTAssertEqual(oneLine.displayOffset(9, in: source), 8)
|
|
325
|
+
XCTAssertEqual(oneLine.displayOffset(-3, in: source), 0)
|
|
326
|
+
XCTAssertEqual(oneLine.displayOffset(99, in: source), 14)
|
|
327
|
+
let wrapping = text(nil)
|
|
328
|
+
XCTAssertEqual(wrapping.text, source)
|
|
329
|
+
XCTAssertEqual(wrapping.displayOffset(9, in: source), 9)
|
|
330
|
+
XCTAssertEqual(wrapping.displayOffset(99, in: source), 15)
|
|
331
|
+
}
|
|
332
|
+
|
|
63
333
|
func testSmallNumberRunsPreserveBaselineAcrossAmountsFiatAndFee() throws {
|
|
64
334
|
func segments(_ prefix: String, _ suffix: String) -> [[String: Any]] {
|
|
65
335
|
[["text": prefix], ["text": "5", "style": "subscript"], ["text": suffix]]
|
|
@@ -1228,7 +1228,9 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1228
1228
|
list.layoutIfNeeded()
|
|
1229
1229
|
let header = try XCTUnwrap(slots[0].superview)
|
|
1230
1230
|
XCTAssertTrue(header.clipsToBounds)
|
|
1231
|
-
XCTAssertEqual(header.bounds.height,
|
|
1231
|
+
XCTAssertEqual(header.bounds.height, 44, "The mounted Fabric header reserves its first-frame height")
|
|
1232
|
+
let firstRow = try XCTUnwrap(list.layoutAttributesForItem(at: IndexPath(item: 0, section: 0)))
|
|
1233
|
+
XCTAssertEqual(firstRow.frame.minY, 44, accuracy: 0.5)
|
|
1232
1234
|
|
|
1233
1235
|
view.setContainerSlotHeightsJson("[44,44,60,0]")
|
|
1234
1236
|
view.layoutIfNeeded()
|
|
@@ -1245,6 +1247,143 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1245
1247
|
XCTAssertNil(slots[2].superview)
|
|
1246
1248
|
}
|
|
1247
1249
|
|
|
1250
|
+
func testPendingHeaderReservesMountedGeometryInEitherPropertyOrder() throws {
|
|
1251
|
+
for pendingBeforeMount in [true, false] {
|
|
1252
|
+
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 708))
|
|
1253
|
+
view.applySnapshotJson(try scrollingSnapshot(count: 3))
|
|
1254
|
+
let header = UIView(frame: CGRect(x: 16, y: 0, width: 288, height: 44.2))
|
|
1255
|
+
if pendingBeforeMount { view.setContainerSlotHeightsJson("[null,0,0,0,0,0]") }
|
|
1256
|
+
view.mountContainerSlot(header, atIndex: 0)
|
|
1257
|
+
if !pendingBeforeMount { view.setContainerSlotHeightsJson("[null,0,0,0,0,0]") }
|
|
1258
|
+
view.layoutIfNeeded()
|
|
1259
|
+
let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
1260
|
+
list.layoutIfNeeded()
|
|
1261
|
+
let host = try XCTUnwrap(header.superview)
|
|
1262
|
+
XCTAssertTrue(host.clipsToBounds)
|
|
1263
|
+
XCTAssertEqual(host.bounds.height, 45, accuracy: 0.5)
|
|
1264
|
+
let firstRow = try XCTUnwrap(list.layoutAttributesForItem(at: IndexPath(item: 0, section: 0)))
|
|
1265
|
+
XCTAssertEqual(firstRow.frame.minY, 45, accuracy: 0.5)
|
|
1266
|
+
|
|
1267
|
+
view.setContainerSlotHeightsJson("[null,0,18,0,0,0]")
|
|
1268
|
+
view.layoutIfNeeded()
|
|
1269
|
+
list.layoutIfNeeded()
|
|
1270
|
+
XCTAssertEqual(host.bounds.height, 45, accuracy: 0.5)
|
|
1271
|
+
XCTAssertEqual(list.layoutAttributesForItem(
|
|
1272
|
+
at: IndexPath(item: 0, section: 0))?.frame.minY, 45)
|
|
1273
|
+
|
|
1274
|
+
view.setContainerSlotHeightsJson("[18,0,0,0,0,0]")
|
|
1275
|
+
view.layoutIfNeeded()
|
|
1276
|
+
list.layoutIfNeeded()
|
|
1277
|
+
XCTAssertEqual(host.bounds.height, 18, accuracy: 0.5)
|
|
1278
|
+
XCTAssertEqual(list.collectionViewLayout.layoutAttributesForItem(
|
|
1279
|
+
at: IndexPath(item: 0, section: 0))?.frame.minY, 18)
|
|
1280
|
+
view.setContainerSlotHeightsJson("[0,0,0,0,0,0]")
|
|
1281
|
+
view.layoutIfNeeded()
|
|
1282
|
+
list.layoutIfNeeded()
|
|
1283
|
+
XCTAssertEqual(host.bounds.height, 0)
|
|
1284
|
+
XCTAssertEqual(list.collectionViewLayout.layoutAttributesForItem(
|
|
1285
|
+
at: IndexPath(item: 0, section: 0))?.frame.minY, 0)
|
|
1286
|
+
view.dispose()
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
func testNumericHeaderHeightIsAuthoritativeBeforeRootMounts() throws {
|
|
1291
|
+
for height in [0, 24] {
|
|
1292
|
+
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 708))
|
|
1293
|
+
view.setContainerSlotHeightsJson("[\(height),0,0,0]")
|
|
1294
|
+
view.applySnapshotJson(try scrollingSnapshot(count: 3))
|
|
1295
|
+
let header = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 44))
|
|
1296
|
+
view.mountContainerSlot(header, atIndex: 0)
|
|
1297
|
+
view.layoutIfNeeded()
|
|
1298
|
+
let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
1299
|
+
list.layoutIfNeeded()
|
|
1300
|
+
XCTAssertEqual(header.superview?.bounds.height, CGFloat(height))
|
|
1301
|
+
XCTAssertEqual(list.layoutAttributesForItem(
|
|
1302
|
+
at: IndexPath(item: 0, section: 0))?.frame.minY, CGFloat(height))
|
|
1303
|
+
view.dispose()
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
func testPendingHeaderDoesNotInheritAnUnmountedRootsHeight() throws {
|
|
1308
|
+
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 708))
|
|
1309
|
+
view.applySnapshotJson(try scrollingSnapshot(count: 3))
|
|
1310
|
+
view.setContainerSlotHeightsJson("[null,0,0,0,0,0]")
|
|
1311
|
+
let first = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 44))
|
|
1312
|
+
view.mountContainerSlot(first, atIndex: 0)
|
|
1313
|
+
XCTAssertEqual(first.superview?.bounds.height, 44)
|
|
1314
|
+
view.unmountContainerSlot(first)
|
|
1315
|
+
let empty = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 0))
|
|
1316
|
+
view.mountContainerSlot(empty, atIndex: 0)
|
|
1317
|
+
XCTAssertEqual(empty.superview?.bounds.height, 0)
|
|
1318
|
+
view.unmountContainerSlot(empty)
|
|
1319
|
+
let replacement = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 27))
|
|
1320
|
+
view.mountContainerSlot(replacement, atIndex: 0)
|
|
1321
|
+
XCTAssertEqual(replacement.superview?.bounds.height, 27)
|
|
1322
|
+
view.setContainerSlotHeightsJson("[0,0,0,0,0,0]")
|
|
1323
|
+
view.unmountContainerSlot(replacement)
|
|
1324
|
+
let authoritativeZero = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 60))
|
|
1325
|
+
view.mountContainerSlot(authoritativeZero, atIndex: 0)
|
|
1326
|
+
XCTAssertEqual(authoritativeZero.superview?.bounds.height, 0)
|
|
1327
|
+
view.dispose()
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
func testPendingHeaderOnlyAcceptsNullAtTheHeaderSlot() throws {
|
|
1331
|
+
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 708))
|
|
1332
|
+
view.setContainerSlotHeightsJson("[24,0,0,0,0,0]")
|
|
1333
|
+
let header = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 44))
|
|
1334
|
+
view.mountContainerSlot(header, atIndex: 0)
|
|
1335
|
+
for invalid in ["[null,null,0,0,0,0]", "[\"invalid\",0,0,0,0,0]",
|
|
1336
|
+
"[null,0,0,0,-1,0]", "[null,0,0,0,0,null]"] {
|
|
1337
|
+
view.setContainerSlotHeightsJson(invalid)
|
|
1338
|
+
XCTAssertEqual(header.superview?.bounds.height, 24)
|
|
1339
|
+
}
|
|
1340
|
+
view.dispose()
|
|
1341
|
+
}
|
|
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
|
+
|
|
1248
1387
|
func testSidecarCentersRowsWhenConfiguredBeforeFirstWidth() throws {
|
|
1249
1388
|
try assertHomeSidecarGeometry(sidecarBeforeFirstLayout: true)
|
|
1250
1389
|
}
|
|
@@ -2559,8 +2698,10 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2559
2698
|
view.setContainerSlotHeightsJson("[0,0,60,0]")
|
|
2560
2699
|
let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
2561
2700
|
list.contentInsetAdjustmentBehavior = .never
|
|
2562
|
-
|
|
2563
|
-
|
|
2701
|
+
// Six retained rows plus 129 retiring rows still exceed the 128-host limit
|
|
2702
|
+
// inside three viewports, without materializing hundreds of 1-point cells.
|
|
2703
|
+
view.applySnapshotJson(try structuralRowsSnapshot(count: 135, generation: 1,
|
|
2704
|
+
uniformHeight: 10))
|
|
2564
2705
|
view.layoutIfNeeded()
|
|
2565
2706
|
list.layoutIfNeeded()
|
|
2566
2707
|
drainMainQueue()
|
|
@@ -2573,7 +2714,7 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2573
2714
|
}
|
|
2574
2715
|
defer { NotificationCenter.default.removeObserver(observer) }
|
|
2575
2716
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 6, generation: 2,
|
|
2576
|
-
transitionID: "tail-host-limit", durationMs: 400, uniformHeight:
|
|
2717
|
+
transitionID: "tail-host-limit", durationMs: 400, uniformHeight: 10))
|
|
2577
2718
|
list.layoutIfNeeded()
|
|
2578
2719
|
let source = try XCTUnwrap(list.dataSource as? UICollectionViewDiffableDataSource<Int, String>)
|
|
2579
2720
|
let flow = try XCTUnwrap(list.collectionViewLayout as? NativeListFlowLayout)
|
|
@@ -2610,22 +2751,41 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2610
2751
|
list.layoutIfNeeded()
|
|
2611
2752
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 50, generation: 2,
|
|
2612
2753
|
transitionID: "tail-6-to-50", durationMs: 400))
|
|
2613
|
-
waitForStructuralFrames(0.16)
|
|
2614
2754
|
list.layoutIfNeeded()
|
|
2615
2755
|
let source = try XCTUnwrap(list.dataSource as? UICollectionViewDiffableDataSource<Int, String>)
|
|
2616
2756
|
let flow = try XCTUnwrap(list.collectionViewLayout as? NativeListFlowLayout)
|
|
2617
2757
|
XCTAssertEqual(source.snapshot().itemIdentifiers, (0..<50).map { "row-\($0)" })
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2758
|
+
var checkedActiveTail = false
|
|
2759
|
+
func checkActiveTail() {
|
|
2760
|
+
guard let clip = flow.tailClip else { return }
|
|
2761
|
+
checkedActiveTail = true
|
|
2762
|
+
list.layoutIfNeeded()
|
|
2763
|
+
XCTAssertGreaterThanOrEqual(clip.endY, 360)
|
|
2764
|
+
XCTAssertLessThanOrEqual(clip.endY, 3000)
|
|
2765
|
+
let suffixCells = list.visibleCells.filter {
|
|
2766
|
+
(list.indexPath(for: $0)?.item ?? -1) >= 6
|
|
2767
|
+
}
|
|
2768
|
+
if clip.endY > list.contentOffset.y + 60 {
|
|
2769
|
+
XCTAssertFalse(suffixCells.isEmpty)
|
|
2770
|
+
}
|
|
2771
|
+
XCTAssertTrue(suffixCells.allSatisfy {
|
|
2772
|
+
!$0.isUserInteractionEnabled && $0.accessibilityElementsHidden
|
|
2773
|
+
})
|
|
2774
|
+
XCTAssertEqual(list.contentOffset.y, 1000, accuracy: 1)
|
|
2775
|
+
}
|
|
2776
|
+
// Inspect actual active frames instead of assuming a delayed callback lands
|
|
2777
|
+
// inside a 400 ms animation on a busy CI runner.
|
|
2778
|
+
checkActiveTail()
|
|
2779
|
+
let probe = Timer(timeInterval: 1.0 / 60, repeats: true) { _ in checkActiveTail() }
|
|
2780
|
+
RunLoop.main.add(probe, forMode: .common)
|
|
2781
|
+
defer { probe.invalidate() }
|
|
2782
|
+
let finished = XCTNSPredicateExpectation(predicate: NSPredicate { _, _ in
|
|
2783
|
+
flow.tailClip == nil &&
|
|
2784
|
+
Mirror(reflecting: view).descendant("structuralDisplayLink") as? CADisplayLink == nil
|
|
2785
|
+
}, object: nil)
|
|
2786
|
+
wait(for: [finished], timeout: 5)
|
|
2787
|
+
probe.invalidate()
|
|
2788
|
+
XCTAssertTrue(checkedActiveTail)
|
|
2629
2789
|
list.layoutIfNeeded()
|
|
2630
2790
|
XCTAssertEqual(source.snapshot().itemIdentifiers, (0..<50).map { "row-\($0)" })
|
|
2631
2791
|
XCTAssertEqual(list.contentSize.height, 3060, accuracy: 1)
|
|
@@ -44,20 +44,29 @@ final class NativeListMediaVisibilityTests: XCTestCase {
|
|
|
44
44
|
@MainActor
|
|
45
45
|
final class NativeListMediaFrameCaptureTests: XCTestCase {
|
|
46
46
|
func testVisibleVideoReleasesPlayerAfterCapturingFirstFrame() throws {
|
|
47
|
+
XCTAssertEqual(UIApplication.shared.applicationState, .active, "Video capture requires a foreground app host")
|
|
47
48
|
let url = try writeVideo()
|
|
48
49
|
defer { try? FileManager.default.removeItem(at: url) }
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
let sceneWindow = UIApplication.shared.connectedScenes
|
|
51
|
+
.compactMap { $0 as? UIWindowScene }
|
|
52
|
+
.first(where: { $0.activationState == .foregroundActive })?
|
|
53
|
+
.windows.first(where: { $0.isKeyWindow })
|
|
54
|
+
let window = try XCTUnwrap(sceneWindow ?? UIApplication.shared.delegate?.window ?? nil)
|
|
55
|
+
let rootView = try XCTUnwrap(window.rootViewController?.view)
|
|
56
|
+
XCTAssertFalse(window.isHidden, "Video capture requires a visible app window")
|
|
57
|
+
let container = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
|
|
58
|
+
rootView.addSubview(container)
|
|
59
|
+
defer { container.removeFromSuperview() }
|
|
53
60
|
let slot = NativeListMediaPreviewSlot()
|
|
54
61
|
slot.view.frame = CGRect(x: 0, y: 0, width: 120, height: 120)
|
|
55
|
-
|
|
62
|
+
container.addSubview(slot.view)
|
|
56
63
|
slot.view.layoutIfNeeded()
|
|
64
|
+
XCTAssertTrue(slot.view.window === window)
|
|
65
|
+
XCTAssertTrue(NativeListMediaPreviewSlot.intersectsViewport(slot.view))
|
|
57
66
|
|
|
58
67
|
var loaded: Bool?
|
|
59
68
|
slot.bind(["uri": url.absoluteString], key: "video", probeOrder: ["video"]) { loaded = $0 }
|
|
60
|
-
|
|
69
|
+
// The cache lookup precedes player creation and can complete asynchronously.
|
|
61
70
|
let deadline = Date().addingTimeInterval(10)
|
|
62
71
|
while slot.capturedFrame == nil, Date() < deadline {
|
|
63
72
|
RunLoop.main.run(until: Date().addingTimeInterval(0.05))
|
|
@@ -68,13 +77,38 @@ final class NativeListMediaFrameCaptureTests: XCTestCase {
|
|
|
68
77
|
XCTAssertFalse(slot.hasLivePlayer)
|
|
69
78
|
|
|
70
79
|
// Leaving and re-entering the viewport keeps the still without rebuilding a player.
|
|
80
|
+
let playersBeforeDetach = slot.createdPlayerCount
|
|
71
81
|
slot.view.removeFromSuperview()
|
|
72
|
-
|
|
82
|
+
XCTAssertTrue(slot.capturedFrame === frame, "Detaching has no replacement screen scale")
|
|
83
|
+
XCTAssertEqual(slot.createdPlayerCount, playersBeforeDetach)
|
|
84
|
+
container.addSubview(slot.view)
|
|
73
85
|
slot.bind(["uri": url.absoluteString], key: "video", probeOrder: ["video"])
|
|
86
|
+
XCTAssertTrue(slot.capturedFrame === frame, "The same window retains the same tier")
|
|
87
|
+
XCTAssertEqual(slot.createdPlayerCount, playersBeforeDetach)
|
|
74
88
|
XCTAssertFalse(slot.hasLivePlayer)
|
|
75
89
|
XCTAssertNotNil(slot.capturedFrame)
|
|
76
90
|
slot.recycle()
|
|
77
91
|
XCTAssertNil(slot.capturedFrame)
|
|
92
|
+
let coldPlayers = slot.createdPlayerCount
|
|
93
|
+
slot.bind(["uri": url.absoluteString], key: "different-row", probeOrder: ["video"])
|
|
94
|
+
let warmDeadline = Date().addingTimeInterval(3)
|
|
95
|
+
while slot.capturedFrame == nil, Date() < warmDeadline {
|
|
96
|
+
RunLoop.main.run(until: Date().addingTimeInterval(0.01))
|
|
97
|
+
}
|
|
98
|
+
XCTAssertNotNil(slot.capturedFrame)
|
|
99
|
+
XCTAssertEqual(slot.createdPlayerCount, coldPlayers, "Recycled row reuses the cached still")
|
|
100
|
+
let second = NativeListMediaPreviewSlot()
|
|
101
|
+
second.view.frame = CGRect(x: 120, y: 0, width: 120, height: 120)
|
|
102
|
+
container.addSubview(second.view)
|
|
103
|
+
second.view.layoutIfNeeded()
|
|
104
|
+
second.bind(["uri": url.absoluteString], key: "another-cell", probeOrder: ["video"])
|
|
105
|
+
let crossCellDeadline = Date().addingTimeInterval(3)
|
|
106
|
+
while second.capturedFrame == nil, Date() < crossCellDeadline {
|
|
107
|
+
RunLoop.main.run(until: Date().addingTimeInterval(0.01))
|
|
108
|
+
}
|
|
109
|
+
XCTAssertNotNil(second.capturedFrame)
|
|
110
|
+
XCTAssertEqual(second.createdPlayerCount, 0, "A different cell uses shared cached pixels")
|
|
111
|
+
second.recycle(); slot.recycle()
|
|
78
112
|
}
|
|
79
113
|
|
|
80
114
|
/// A 64×48, ten-frame H.264 MP4 (generated with AVAssetWriter on macOS); the simulator
|
package/lib/module/NativeList.js
CHANGED
|
@@ -91,10 +91,21 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
91
91
|
}
|
|
92
92
|
const expandedEpoch = disclosureSlotMounts.current.expandedEpoch;
|
|
93
93
|
const toggleEpoch = disclosureSlotMounts.current.toggleEpoch;
|
|
94
|
+
const iosHeaderPresent = Platform.OS === 'ios' && listHeader != null;
|
|
94
95
|
const [slotMeasurements, setSlotMeasurements] = useState({
|
|
95
96
|
heights: [0, 0, 0, 0, 0, 0],
|
|
96
|
-
readyEpochs: [-1, -1, -1, -1, -1, -1]
|
|
97
|
+
readyEpochs: [-1, -1, -1, -1, -1, -1],
|
|
98
|
+
iosHeaderPresent,
|
|
99
|
+
headerEpoch: 0
|
|
97
100
|
});
|
|
101
|
+
if (slotMeasurements.iosHeaderPresent !== iosHeaderPresent) {
|
|
102
|
+
setSlotMeasurements({
|
|
103
|
+
...slotMeasurements,
|
|
104
|
+
iosHeaderPresent,
|
|
105
|
+
headerEpoch: slotMeasurements.headerEpoch + 1
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const headerEpoch = slotMeasurements.headerEpoch;
|
|
98
109
|
const hasSidecar = listSidecar !== undefined;
|
|
99
110
|
const sidecarWidth = sidecarLayout?.width;
|
|
100
111
|
const sidecarGap = sidecarLayout?.gap;
|
|
@@ -155,7 +166,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
155
166
|
const [viewportWidth, setViewportWidth] = useState(0);
|
|
156
167
|
const [topOverlayHeight, setTopOverlayHeight] = useState(0);
|
|
157
168
|
const hasTopOverlay = Platform?.OS === 'ios' && parseInt(String(Platform.Version), 10) >= 26 && (topScrollEdgeEffect === 'hard' || topScrollEdgeEffect === 'soft') && topOverlay != null;
|
|
158
|
-
const containerSlotHeightsJson = JSON.stringify(slotHeights);
|
|
169
|
+
const containerSlotHeightsJson = JSON.stringify(Platform.OS === 'ios' && (!iosHeaderPresent || slotMeasurements.readyEpochs[0] !== headerEpoch) ? [iosHeaderPresent ? null : 0, ...slotHeights.slice(1)] : slotHeights);
|
|
159
170
|
const defaultSlotInset = snapshot.layout.contentPaddingHorizontal ?? snapshot.layout.contentPadding ?? 0;
|
|
160
171
|
const bandWidth = sidecarLayout ? Math.min(viewportWidth, sidecarLayout.maxContentWidth) : 0;
|
|
161
172
|
const slotInset = sidecarLayout ? Math.max(0, (viewportWidth - bandWidth) / 2) + defaultSlotInset : defaultSlotInset;
|
|
@@ -166,6 +177,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
166
177
|
return;
|
|
167
178
|
}
|
|
168
179
|
setSlotMeasurements(previous => {
|
|
180
|
+
if (index === 0 && epoch !== previous.headerEpoch) return previous;
|
|
169
181
|
if (previous.heights[index] === height && previous.readyEpochs[index] === epoch) {
|
|
170
182
|
return previous;
|
|
171
183
|
}
|
|
@@ -174,6 +186,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
174
186
|
heights[index] = height;
|
|
175
187
|
readyEpochs[index] = epoch;
|
|
176
188
|
return {
|
|
189
|
+
...previous,
|
|
177
190
|
heights,
|
|
178
191
|
readyEpochs
|
|
179
192
|
};
|
|
@@ -521,7 +534,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
521
534
|
},
|
|
522
535
|
onLayout: event => {
|
|
523
536
|
if (index < 4) {
|
|
524
|
-
recordSlotLayout(index, Math.ceil(event.nativeEvent.layout.height), 0);
|
|
537
|
+
recordSlotLayout(index, Math.ceil(event.nativeEvent.layout.height), index === 0 ? headerEpoch : 0);
|
|
525
538
|
}
|
|
526
539
|
},
|
|
527
540
|
children: index >= 4 ? /*#__PURE__*/_jsx(View, {
|
|
@@ -530,7 +543,7 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
530
543
|
onLayout: event => recordSlotLayout(index, Math.ceil(event.nativeEvent.layout.height), index === 4 ? expandedEpoch : toggleEpoch),
|
|
531
544
|
children: content
|
|
532
545
|
}, index === 4 ? `expanded-${expandedEpoch}` : `toggle-${toggleEpoch}`) : content
|
|
533
|
-
}, index)), hasTopOverlay ? /*#__PURE__*/_jsx(View, {
|
|
546
|
+
}, index === 0 && Platform.OS === 'ios' ? `header-${headerEpoch}` : index)), hasTopOverlay ? /*#__PURE__*/_jsx(View, {
|
|
534
547
|
collapsable: false,
|
|
535
548
|
style: {
|
|
536
549
|
position: 'absolute',
|
|
@@ -385,7 +385,9 @@ export const NativeList = /*#__PURE__*/forwardRef(function NativeList({
|
|
|
385
385
|
testID: "native-list-structure-toggle-slot",
|
|
386
386
|
"aria-hidden": !slotState.disclosurePresent,
|
|
387
387
|
pointerEvents: slotState.disclosurePresent ? 'auto' : 'none',
|
|
388
|
-
style: slotState.disclosurePresent ?
|
|
388
|
+
style: slotState.disclosurePresent ? {
|
|
389
|
+
marginHorizontal: -padding
|
|
390
|
+
} : collapsedExpandedContentStyle,
|
|
389
391
|
children: listStructureToggle
|
|
390
392
|
}) : null, slotState.expandedTrailingInset > 0 && (listExpandedContent !== undefined || listStructureToggle !== undefined) ? /*#__PURE__*/_jsx(View, {
|
|
391
393
|
testID: "native-list-trailing-inset-slot",
|