@onekeyfe/react-native-native-list 3.0.157-alpha.258 → 3.0.157-alpha.273
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 +17 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +55 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListScrollAlignment.kt +29 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListScrollPositionTracker.kt +30 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +127 -22
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListScrollAlignmentTest.kt +62 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListScrollPositionTrackerTest.kt +16 -0
- package/docs/SPEC.md +85 -17
- package/docs/STYLE_SPEC.md +4 -2
- package/ios/NativeListActivityDetailsView.swift +77 -15
- package/ios/NativeListMediaPreviewSlot.swift +63 -3
- package/ios/NativeListResolvedText.swift +8 -0
- package/ios/NativeListScrollGeometry.swift +27 -0
- package/ios/RNCNativeListView.swift +39 -21
- package/ios/tests/NativeListActivityPresentationTests.swift +54 -0
- package/ios/tests/NativeListLifecycleTests.swift +28 -0
- package/ios/tests/NativeListMediaVisibilityTests.swift +67 -0
- package/lib/module/models.js +1 -1
- package/lib/module/scrolling.js +3 -1
- package/lib/module/validation.js +2 -2
- package/lib/typescript/src/models.d.ts +1 -1
- package/package.json +3 -3
- package/src/models.ts +1 -0
- package/src/scrolling.ts +4 -1
- package/src/validation.ts +1 -6
|
@@ -175,6 +175,34 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
175
175
|
XCTAssertEqual(list.contentOffset.y, maximum, accuracy: 0.5)
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
func testReactSlotFramesCannotMoveSlotsOutOfNativePlacement() throws {
|
|
179
|
+
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 708))
|
|
180
|
+
// Fabric assigns each root the frame React computed: horizontal inset, top 0.
|
|
181
|
+
let slots = (0..<3).map { _ in UIView(frame: CGRect(x: 16, y: 0, width: 288, height: 44)) }
|
|
182
|
+
for (index, slot) in slots.enumerated() { view.mountContainerSlot(slot, atIndex: index) }
|
|
183
|
+
view.applySnapshotJson(try scrollingSnapshot(count: 3))
|
|
184
|
+
view.layoutIfNeeded()
|
|
185
|
+
let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
186
|
+
list.layoutIfNeeded()
|
|
187
|
+
let header = try XCTUnwrap(slots[0].superview)
|
|
188
|
+
XCTAssertTrue(header.clipsToBounds)
|
|
189
|
+
XCTAssertEqual(header.bounds.height, 0, "An unmeasured header cannot draw over the first rows")
|
|
190
|
+
|
|
191
|
+
view.setContainerSlotHeightsJson("[44,44,60]")
|
|
192
|
+
view.layoutIfNeeded()
|
|
193
|
+
list.layoutIfNeeded()
|
|
194
|
+
XCTAssertEqual(slots[0].convert(CGPoint.zero, to: list), CGPoint(x: 16, y: 0))
|
|
195
|
+
let footerY = 44 + 3 * 80 as CGFloat
|
|
196
|
+
XCTAssertEqual(slots[2].convert(CGPoint.zero, to: list).y, footerY)
|
|
197
|
+
// A React height update rewrites the root frame before the new height reaches native.
|
|
198
|
+
slots[2].frame = CGRect(x: 16, y: 0, width: 288, height: 90)
|
|
199
|
+
XCTAssertEqual(slots[2].convert(CGPoint.zero, to: list), CGPoint(x: 16, y: footerY))
|
|
200
|
+
XCTAssertTrue(slots[1].superview?.isHidden == true, "The empty slot stays hidden with rows")
|
|
201
|
+
|
|
202
|
+
view.unmountContainerSlot(slots[2])
|
|
203
|
+
XCTAssertNil(slots[2].superview)
|
|
204
|
+
}
|
|
205
|
+
|
|
178
206
|
private func makeScrollingList() throws -> NativeListView {
|
|
179
207
|
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 708))
|
|
180
208
|
for index in 0..<3 { view.mountContainerSlot(UIView(), atIndex: index) }
|
|
@@ -40,3 +40,70 @@ final class NativeListMediaVisibilityTests: XCTestCase {
|
|
|
40
40
|
XCTAssertFalse(NativeListMediaPreviewSlot.intersectsViewport(tile))
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
@MainActor
|
|
45
|
+
final class NativeListMediaFrameCaptureTests: XCTestCase {
|
|
46
|
+
func testVisibleVideoReleasesPlayerAfterCapturingFirstFrame() throws {
|
|
47
|
+
let url = try writeVideo()
|
|
48
|
+
defer { try? FileManager.default.removeItem(at: url) }
|
|
49
|
+
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
|
|
50
|
+
window.rootViewController = UIViewController()
|
|
51
|
+
window.isHidden = false
|
|
52
|
+
defer { window.isHidden = true }
|
|
53
|
+
let slot = NativeListMediaPreviewSlot()
|
|
54
|
+
slot.view.frame = CGRect(x: 0, y: 0, width: 120, height: 120)
|
|
55
|
+
window.rootViewController?.view.addSubview(slot.view)
|
|
56
|
+
slot.view.layoutIfNeeded()
|
|
57
|
+
|
|
58
|
+
var loaded: Bool?
|
|
59
|
+
slot.bind(["uri": url.absoluteString], key: "video", probeOrder: ["video"]) { loaded = $0 }
|
|
60
|
+
XCTAssertTrue(slot.hasLivePlayer, "A visible tile starts one paused player")
|
|
61
|
+
let deadline = Date().addingTimeInterval(10)
|
|
62
|
+
while slot.capturedFrame == nil, Date() < deadline {
|
|
63
|
+
RunLoop.main.run(until: Date().addingTimeInterval(0.05))
|
|
64
|
+
}
|
|
65
|
+
XCTAssertEqual(loaded, true)
|
|
66
|
+
let frame = try XCTUnwrap(slot.capturedFrame, "The first frame replaces the live player")
|
|
67
|
+
XCTAssertEqual(frame.size, CGSize(width: 64, height: 48))
|
|
68
|
+
XCTAssertFalse(slot.hasLivePlayer)
|
|
69
|
+
|
|
70
|
+
// Leaving and re-entering the viewport keeps the still without rebuilding a player.
|
|
71
|
+
slot.view.removeFromSuperview()
|
|
72
|
+
window.rootViewController?.view.addSubview(slot.view)
|
|
73
|
+
slot.bind(["uri": url.absoluteString], key: "video", probeOrder: ["video"])
|
|
74
|
+
XCTAssertFalse(slot.hasLivePlayer)
|
|
75
|
+
XCTAssertNotNil(slot.capturedFrame)
|
|
76
|
+
slot.recycle()
|
|
77
|
+
XCTAssertNil(slot.capturedFrame)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// A 64×48, ten-frame H.264 MP4 (generated with AVAssetWriter on macOS); the simulator
|
|
81
|
+
/// has no reliable H.264 encoder for writing one at test time.
|
|
82
|
+
private static let videoBase64 = [
|
|
83
|
+
"AAAAHGZ0eXBtcDQyAAAAAWlzb21tcDQxbXA0MgAAAAFtZGF0AAAAAAAAAXQAAAA1BgUtR1ZK3FxMQz+U78URPNFDqAEAAAMA",
|
|
84
|
+
"AQMAAAMAAQIAAeYACwAAAwAAAwAArDoMA5ErAYAAAAA8JbggH94I5Uz/gak9b71ouT+PwABUezojLMLPpBfbqJ15oD1BM5L2",
|
|
85
|
+
"vvLSFvvy+AABSCrnn2hX8nKgIiU0AAAAHSHhEF/Eku94/c0JBdrVAqcS2Y43GYAJD/p9QzWAAAAAGSGogoS/nFT7cZbZ8xnp",
|
|
86
|
+
"PB3mw6AB/xojtyEAAAAXAajBj/+nyteRkHQKsy3f1gAFJajGDXAAAAAVAajDj/9TDF3o0LWPJnRoAJ7STV8lAAAAGSHjIaIl",
|
|
87
|
+
"/wHKBDW4y227MDl54AH+VxDvqGgAAAAUIakGhL9JSwD9lXLr+gAf8c7Z0iAAAAATAalFiT9cnuAKgJxY0AGV0YL85AAAABEB",
|
|
88
|
+
"qUeJP1ye5zMOKAAol0Uv0AAAABQh5SWiJf8BygQQ1yj2ACX52k6mwAAAA0xtb292AAAAbG12aGQAAAAA5uAsIObgLCAAAAJY",
|
|
89
|
+
"AAACWAABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
|
90
|
+
"AAAAAAAAAAAAAAACAAAC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AAY",
|
|
100
|
+
"AAAAFHN0Y28AAAAAAAAAAQAAACw=",
|
|
101
|
+
].joined()
|
|
102
|
+
|
|
103
|
+
private func writeVideo() throws -> URL {
|
|
104
|
+
let url = FileManager.default.temporaryDirectory
|
|
105
|
+
.appendingPathComponent("native-list-frame-\(UUID().uuidString).mp4")
|
|
106
|
+
try XCTUnwrap(Data(base64Encoded: Self.videoBase64)).write(to: url)
|
|
107
|
+
return url
|
|
108
|
+
}
|
|
109
|
+
}
|
package/lib/module/models.js
CHANGED
|
@@ -16,7 +16,7 @@ export const ROW_BOX_STYLE_KEYS_BY_TYPE = {
|
|
|
16
16
|
identity: ['horizontalPadding', 'verticalPadding', 'leadingGap', 'lineGap', 'titleBadgeGap', 'trailingGap', 'image'],
|
|
17
17
|
walletGroup: ['horizontalPadding', 'verticalPadding'],
|
|
18
18
|
rail: ['horizontalPadding', 'verticalPadding', 'leadingGap', 'titleBadgeGap', 'trailingGap', 'image'],
|
|
19
|
-
activity: ['horizontalPadding', 'verticalPadding', 'leadingGap', 'lineGap', 'trailingGap', 'image'],
|
|
19
|
+
activity: ['horizontalPadding', 'verticalPadding', 'leadingGap', 'lineGap', 'titleBadgeGap', 'trailingGap', 'image'],
|
|
20
20
|
message: ['horizontalPadding', 'verticalPadding', 'leadingGap', 'lineGap', 'image'],
|
|
21
21
|
dataRow: ['horizontalPadding', 'verticalPadding', 'leadingGap', 'lineGap', 'titleBadgeGap', 'image'],
|
|
22
22
|
market: ['horizontalPadding', 'verticalPadding', 'leadingGap', 'lineGap', 'titleBadgeGap', 'trailingGap', 'image'],
|
package/lib/module/scrolling.js
CHANGED
|
@@ -115,7 +115,9 @@ export function calculateAlignedScrollOffset({
|
|
|
115
115
|
if (alignment === 'nearest') {
|
|
116
116
|
if (itemOffset < currentOffset) resolvedPosition = 0;else if (itemOffset + itemLength > currentOffset + viewportLength) resolvedPosition = 1;else return currentOffset;
|
|
117
117
|
}
|
|
118
|
-
const
|
|
118
|
+
const alignmentSpace = viewportLength - itemLength;
|
|
119
|
+
// Explicit positions align oversized rows too; preserve legacy nearest calls.
|
|
120
|
+
const target = itemOffset - resolvedPosition * (alignment === 'nearest' ? Math.max(0, alignmentSpace) : alignmentSpace) - viewOffset;
|
|
119
121
|
return Math.min(Math.max(0, target), Math.max(0, contentLength - viewportLength));
|
|
120
122
|
}
|
|
121
123
|
//# sourceMappingURL=scrolling.js.map
|
package/lib/module/validation.js
CHANGED
|
@@ -128,13 +128,13 @@ const TEXT_STYLE_KEYS_BY_ROW_TYPE = {
|
|
|
128
128
|
identity: ['title', 'subtitle', 'tertiary', 'badge', 'value', 'valueSecondary'],
|
|
129
129
|
walletGroup: [],
|
|
130
130
|
rail: ['title', 'badge', 'status'],
|
|
131
|
-
activity: ['title', 'description', 'status', '
|
|
131
|
+
activity: ['title', 'description', 'status', 'primaryAmount', 'secondaryAmount'],
|
|
132
132
|
message: ['title', 'body', 'time'],
|
|
133
133
|
dataRow: ['columns', 'columnSecondary', 'index'],
|
|
134
134
|
market: ['title', 'subtitle', 'price', 'change'],
|
|
135
135
|
mediaTile: ['title', 'subtitle', 'badge'],
|
|
136
136
|
metricCard: ['title', 'value', 'subtitle', 'trend'],
|
|
137
|
-
sectionHeader: ['
|
|
137
|
+
sectionHeader: ['title', 'subtitle', 'value'],
|
|
138
138
|
action: ['title', 'value'],
|
|
139
139
|
system: ['title', 'message', 'actionText']
|
|
140
140
|
};
|
|
@@ -87,7 +87,7 @@ export declare const ROW_BOX_STYLE_KEYS_BY_TYPE: {
|
|
|
87
87
|
readonly identity: readonly ["horizontalPadding", "verticalPadding", "leadingGap", "lineGap", "titleBadgeGap", "trailingGap", "image"];
|
|
88
88
|
readonly walletGroup: readonly ["horizontalPadding", "verticalPadding"];
|
|
89
89
|
readonly rail: readonly ["horizontalPadding", "verticalPadding", "leadingGap", "titleBadgeGap", "trailingGap", "image"];
|
|
90
|
-
readonly activity: readonly ["horizontalPadding", "verticalPadding", "leadingGap", "lineGap", "trailingGap", "image"];
|
|
90
|
+
readonly activity: readonly ["horizontalPadding", "verticalPadding", "leadingGap", "lineGap", "titleBadgeGap", "trailingGap", "image"];
|
|
91
91
|
readonly message: readonly ["horizontalPadding", "verticalPadding", "leadingGap", "lineGap", "image"];
|
|
92
92
|
readonly dataRow: readonly ["horizontalPadding", "verticalPadding", "leadingGap", "lineGap", "titleBadgeGap", "image"];
|
|
93
93
|
readonly market: readonly ["horizontalPadding", "verticalPadding", "leadingGap", "lineGap", "titleBadgeGap", "trailingGap", "image"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-native-list",
|
|
3
|
-
"version": "3.0.157-alpha.
|
|
3
|
+
"version": "3.0.157-alpha.273",
|
|
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",
|
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
"typescript": "^5.9.2"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@onekeyfe/react-native-image": "3.0.157-alpha.
|
|
88
|
-
"@onekeyfe/react-native-native-logger": "3.0.157-alpha.
|
|
87
|
+
"@onekeyfe/react-native-image": "3.0.157-alpha.273",
|
|
88
|
+
"@onekeyfe/react-native-native-logger": "3.0.157-alpha.273",
|
|
89
89
|
"react": "*",
|
|
90
90
|
"react-native": "*",
|
|
91
91
|
"react-native-nitro-modules": "0.37.0"
|
package/src/models.ts
CHANGED
package/src/scrolling.ts
CHANGED
|
@@ -178,9 +178,12 @@ export function calculateAlignedScrollOffset({
|
|
|
178
178
|
resolvedPosition = 1;
|
|
179
179
|
else return currentOffset;
|
|
180
180
|
}
|
|
181
|
+
const alignmentSpace = viewportLength - itemLength;
|
|
182
|
+
// Explicit positions align oversized rows too; preserve legacy nearest calls.
|
|
181
183
|
const target =
|
|
182
184
|
itemOffset -
|
|
183
|
-
resolvedPosition *
|
|
185
|
+
resolvedPosition *
|
|
186
|
+
(alignment === 'nearest' ? Math.max(0, alignmentSpace) : alignmentSpace) -
|
|
184
187
|
viewOffset;
|
|
185
188
|
return Math.min(
|
|
186
189
|
Math.max(0, target),
|
package/src/validation.ts
CHANGED
|
@@ -175,11 +175,6 @@ const TEXT_STYLE_KEYS_BY_ROW_TYPE: Readonly<
|
|
|
175
175
|
'title',
|
|
176
176
|
'description',
|
|
177
177
|
'status',
|
|
178
|
-
'amounts',
|
|
179
|
-
'badges',
|
|
180
|
-
'presentation',
|
|
181
|
-
'fee',
|
|
182
|
-
'descriptionActionKey',
|
|
183
178
|
'primaryAmount',
|
|
184
179
|
'secondaryAmount',
|
|
185
180
|
],
|
|
@@ -188,7 +183,7 @@ const TEXT_STYLE_KEYS_BY_ROW_TYPE: Readonly<
|
|
|
188
183
|
market: ['title', 'subtitle', 'price', 'change'],
|
|
189
184
|
mediaTile: ['title', 'subtitle', 'badge'],
|
|
190
185
|
metricCard: ['title', 'value', 'subtitle', 'trend'],
|
|
191
|
-
sectionHeader: ['
|
|
186
|
+
sectionHeader: ['title', 'subtitle', 'value'],
|
|
192
187
|
action: ['title', 'value'],
|
|
193
188
|
system: ['title', 'message', 'actionText'],
|
|
194
189
|
};
|