@onekeyfe/react-native-native-list 6.7.0-2 → 6.7.0-21
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/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +245 -9
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +35 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +147 -33
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +149 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +51 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1953 -117
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
- package/docs/ROW_TEMPLATES.md +70 -11
- package/docs/SPEC.md +1235 -20
- package/docs/STYLE_SPEC.md +6 -0
- package/ios/HybridNativeList.swift +21 -2
- package/ios/NativeListAccessoryStack.swift +235 -39
- package/ios/NativeListActivityDetailsView.swift +30 -11
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +155 -27
- package/ios/NativeListDesignAssets.swift +9 -0
- package/ios/NativeListIdentityRenderer.swift +239 -31
- package/ios/NativeListLeadingVisual.swift +119 -22
- package/ios/NativeListMarketRenderer.swift +113 -18
- package/ios/NativeListMessageRenderer.swift +34 -1
- package/ios/NativeListModels.swift +42 -2
- package/ios/NativeListRendererRegistry.swift +1 -0
- package/ios/NativeListResolvedText.swift +2 -1
- package/ios/NativeListRowHost.swift +14 -0
- package/ios/NativeListSectionHeaderRenderer.swift +88 -0
- package/ios/RNCNativeListView.swift +1052 -58
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +4 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +3 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/icon.svg +1 -0
- package/ios/tests/NativeListAccessoryStackTests.swift +89 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +153 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
- package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
- package/ios/tests/NativeListLifecycleTests.swift +2789 -3
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/lib/module/NativeList.js +223 -36
- package/lib/module/NativeList.web.js +260 -33
- package/lib/module/index.js +1 -1
- package/lib/module/models.js +3 -0
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +1386 -81
- package/lib/module/web/NativeListWebEngine.js +914 -80
- package/lib/module/web/templates/ActivityRowRenderer.js +487 -7
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
- package/lib/module/web/templates/DataRowRenderer.js +40 -5
- package/lib/module/web/templates/IdentityRowRenderer.js +145 -5
- package/lib/module/web/templates/MarketRowRenderer.js +8 -3
- package/lib/module/web/templates/MarketTableRowRenderer.js +577 -0
- package/lib/module/web/templates/MediaTileRowRenderer.js +260 -5
- package/lib/module/web/templates/MessageRowRenderer.js +18 -2
- package/lib/module/web/templates/RowContainerStyle.js +1 -0
- package/lib/module/web/templates/RowRendererRegistry.js +8 -3
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +70 -3
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/lib/typescript/src/NativeList.d.ts +3 -3
- package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
- package/lib/typescript/src/NativeList.types.d.ts +29 -1
- package/lib/typescript/src/NativeList.web.d.ts +2 -2
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +196 -17
- package/lib/typescript/src/validation.d.ts +20 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +58 -1
- package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
- package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/MarketTableRowRenderer.d.ts +17 -0
- package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +3 -3
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +10 -4
- package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +3 -1
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/package.json +3 -3
- package/react-native-native-list.podspec +1 -0
- package/src/NativeList.nitro.ts +2 -0
- package/src/NativeList.tsx +418 -89
- package/src/NativeList.types.ts +34 -1
- package/src/NativeList.web.tsx +417 -66
- package/src/index.ts +2 -0
- package/src/models.ts +355 -143
- package/src/selection.ts +1 -0
- package/src/validation.ts +3315 -166
- package/src/web/NativeListWebEngine.ts +1473 -113
- package/src/web/templates/ActivityRowRenderer.ts +732 -8
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +93 -20
- package/src/web/templates/IdentityRowRenderer.ts +217 -6
- package/src/web/templates/MarketRowRenderer.ts +19 -3
- package/src/web/templates/MarketTableRowRenderer.ts +755 -0
- package/src/web/templates/MediaTileRowRenderer.ts +313 -5
- package/src/web/templates/MessageRowRenderer.ts +23 -7
- package/src/web/templates/RowContainerStyle.ts +2 -0
- package/src/web/templates/RowRendererRegistry.ts +21 -6
- package/src/web/templates/SectionHeaderRowRenderer.ts +89 -5
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
|
2
|
+
<path d="M11 16.387a4.5 4.5 0 0 1 0-8.775V6h2v1.613a4.5 4.5 0 0 1 2.856 2.067l-1.712 1.032a2.5 2.5 0 1 0 0 2.576l1.712 1.032A4.5 4.5 0 0 1 13 16.386V18h-2z"/>
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10m-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"images":[{"filename":"icon.svg","idiom":"universal"}],"info":{"author":"xcode","version":1},"properties":{"preserves-vector-representation":true,"template-rendering-intent":"template"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#000"><path d="M12 16H8v-2h4zm4-4H8v-2h8zm0-4H8V6h8z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M20 22H4V2h16zM6 20h12V4H6z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"images":[{"filename":"icon.svg","idiom":"universal"}],"info":{"author":"xcode","version":1},"properties":{"preserves-vector-representation":true,"template-rendering-intent":"template"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#000"><path d="M14 18v4h-4v-4zm0-4h-4v-4h4zm0-8h-4V2h4z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"images":[{"filename":"icon.svg","idiom":"universal"}],"info":{"author":"xcode","version":1},"properties":{"preserves-vector-representation":true,"template-rendering-intent":"template"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#000"><path d="M13 11h8v2h-8v8h-2v-8H3v-2h8V3h2z"/></svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
|
2
|
+
<path d="M5 12a7 7 0 0 0 7 7 7.15 7.15 0 0 0 4.955-2h-2.943v-2h6v6h-2v-2.257A9.148 9.148 0 0 1 12 21a9 9 0 0 1-9-9v-1h2v1Zm1-6.754A9.148 9.148 0 0 1 12 3a9 9 0 0 1 9 9v1h-2v-1a7 7 0 0 0-7-7 7.15 7.15 0 0 0-4.955 2H10v2H4V3h2v2.246Z"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"images":[{"filename":"icon.svg","idiom":"universal"}],"info":{"author":"xcode","version":1},"properties":{"preserves-vector-representation":true,"template-rendering-intent":"template"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#000"><path d="M16 17.01h-2V15h2zm0-4h-2V11h2zm0-4h-2V7h2z"/><path fill-rule="evenodd" clip-rule="evenodd" d="m22 9.927-.629.252c-1.661.665-1.661 2.977 0 3.642l.629.252V20H2v-5.927l.629-.252c1.661-.665 1.661-2.977 0-3.642L2 9.927V4h20zM4 8.636c2.5 1.52 2.499 5.207 0 6.727V18h16v-2.637c-2.499-1.52-2.5-5.208 0-6.727V6H4z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"images":[{"filename":"icon.svg","idiom":"universal"}],"info":{"author":"xcode","version":1},"properties":{"preserves-vector-representation":true,"template-rendering-intent":"template"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#000"><path d="M15.5 13.25a1.25 1.25 0 1 1 0 2.5 1.25 1.25 0 0 1 0-2.5"/><path fill-rule="evenodd" clip-rule="evenodd" d="M17 8h4v13H7a4 4 0 0 1-4-4V6.5A3.5 3.5 0 0 1 6.5 3H17zM5 17a2 2 0 0 0 2 2h12v-9H6.5c-.537 0-1.045-.12-1.5-.337zM6.5 5a1.5 1.5 0 1 0 0 3H15V5z"/></svg>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
import XCTest
|
|
3
|
+
@testable import NativeListModule
|
|
4
|
+
|
|
5
|
+
@MainActor
|
|
6
|
+
final class NativeListAccessoryStackTests: XCTestCase {
|
|
7
|
+
private func makeStack(trailing: [[String: Any]]) throws -> NativeListAccessoryStack {
|
|
8
|
+
let stack = NativeListAccessoryStack(frame: CGRect(x: 0, y: 0, width: 160, height: 48))
|
|
9
|
+
let item = try NativeListItem(data: [
|
|
10
|
+
"key": "doge--0",
|
|
11
|
+
"type": "identity",
|
|
12
|
+
"presentation": "networkSelector",
|
|
13
|
+
"height": 48,
|
|
14
|
+
"title": "Dogecoin",
|
|
15
|
+
"trailing": trailing,
|
|
16
|
+
])
|
|
17
|
+
stack.bind(
|
|
18
|
+
item,
|
|
19
|
+
descriptors: trailing,
|
|
20
|
+
theme: nil,
|
|
21
|
+
style: [:],
|
|
22
|
+
checkboxState: { _, _, fallback in fallback },
|
|
23
|
+
fonts: NativeListFontFamilies()
|
|
24
|
+
)
|
|
25
|
+
stack.layoutIfNeeded()
|
|
26
|
+
return stack
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private func visibleControl(_ stack: NativeListAccessoryStack) throws -> UIView {
|
|
30
|
+
let control = try XCTUnwrap(stack.firstVisibleControl)
|
|
31
|
+
XCTAssertGreaterThan(control.bounds.width, 0)
|
|
32
|
+
XCTAssertGreaterThan(control.bounds.height, 0)
|
|
33
|
+
return control
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// OK-65494: a network balance is display only, so a tap on it must reach the
|
|
37
|
+
// cell and select the row instead of stopping at the accessory button.
|
|
38
|
+
func testValueAccessoryLeavesTouchesToTheRow() throws {
|
|
39
|
+
let stack = try makeStack(trailing: [["kind": "value", "text": "¥110.42"]])
|
|
40
|
+
let value = try visibleControl(stack)
|
|
41
|
+
XCTAssertFalse(value.isUserInteractionEnabled)
|
|
42
|
+
XCTAssertTrue(stack.hitTest(value.center, with: nil) === stack)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
func testValuePairAccessoryLeavesTouchesToTheRow() throws {
|
|
46
|
+
let stack = try makeStack(trailing: [
|
|
47
|
+
["kind": "valuePair", "primary": "$15.60", "secondary": "0.002 BTC"],
|
|
48
|
+
])
|
|
49
|
+
let value = try visibleControl(stack)
|
|
50
|
+
XCTAssertFalse(value.isUserInteractionEnabled)
|
|
51
|
+
XCTAssertTrue(stack.hitTest(value.center, with: nil) === stack)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
func testTextAccessoryWithActionKeepsItsOwnTouches() throws {
|
|
55
|
+
let stack = try makeStack(trailing: [
|
|
56
|
+
["kind": "radio", "checked": true, "actionKey": "network.select"],
|
|
57
|
+
])
|
|
58
|
+
let radio = try visibleControl(stack)
|
|
59
|
+
XCTAssertTrue(radio.isUserInteractionEnabled)
|
|
60
|
+
XCTAssertTrue(stack.hitTest(radio.center, with: nil) === radio)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
func testRebindRestoresTouchOwnershipOfTheReusedButton() throws {
|
|
64
|
+
let stack = try makeStack(trailing: [["kind": "value", "text": "¥110.42"]])
|
|
65
|
+
let value = try visibleControl(stack)
|
|
66
|
+
XCTAssertFalse(value.isUserInteractionEnabled)
|
|
67
|
+
let radioItem = try NativeListItem(data: [
|
|
68
|
+
"key": "doge--0",
|
|
69
|
+
"type": "identity",
|
|
70
|
+
"presentation": "networkSelector",
|
|
71
|
+
"height": 48,
|
|
72
|
+
"title": "Dogecoin",
|
|
73
|
+
])
|
|
74
|
+
let radio: [[String: Any]] = [["kind": "radio", "checked": false, "actionKey": "network.select"]]
|
|
75
|
+
stack.bind(
|
|
76
|
+
radioItem,
|
|
77
|
+
descriptors: radio,
|
|
78
|
+
theme: nil,
|
|
79
|
+
style: [:],
|
|
80
|
+
checkboxState: { _, _, fallback in fallback },
|
|
81
|
+
fonts: NativeListFontFamilies()
|
|
82
|
+
)
|
|
83
|
+
stack.layoutIfNeeded()
|
|
84
|
+
let reused = try visibleControl(stack)
|
|
85
|
+
XCTAssertTrue(reused === value)
|
|
86
|
+
XCTAssertTrue(reused.isUserInteractionEnabled)
|
|
87
|
+
XCTAssertTrue(stack.hitTest(reused.center, with: nil) === reused)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -4,6 +4,62 @@ import XCTest
|
|
|
4
4
|
|
|
5
5
|
@MainActor
|
|
6
6
|
final class NativeListActivityPresentationTests: XCTestCase {
|
|
7
|
+
func testActivityLeadingVisibilityAndFooterAlignmentRestoreOnRebind() throws {
|
|
8
|
+
func item(rich: Bool, hidden: Bool) throws -> NativeListItem {
|
|
9
|
+
var data: [String: Any] = [
|
|
10
|
+
"type": "activity", "key": "tx", "title": "Send", "description": "To Alice",
|
|
11
|
+
"leading": ["kind": "icon", "name": "ArrowTopOutline"],
|
|
12
|
+
"hideLeading": hidden,
|
|
13
|
+
"footerActions": [["key": "speed-up", "label": "Speed up"]],
|
|
14
|
+
]
|
|
15
|
+
if rich { data["amounts"] = [["key": "send", "text": "••••"]] }
|
|
16
|
+
else { data["primaryAmount"] = "••••" }
|
|
17
|
+
return try NativeListItem(data: data)
|
|
18
|
+
}
|
|
19
|
+
let details = NativeListActivityDetailsView()
|
|
20
|
+
let main = try XCTUnwrap(details.arrangedSubviews.first as? UIStackView)
|
|
21
|
+
let richVisual = try XCTUnwrap(main.arrangedSubviews.first)
|
|
22
|
+
let richActions = try XCTUnwrap(details.arrangedSubviews.last as? UIStackView)
|
|
23
|
+
let container = UIView(frame: CGRect(x: 0, y: 0, width: 366, height: 300))
|
|
24
|
+
details.translatesAutoresizingMaskIntoConstraints = false
|
|
25
|
+
container.addSubview(details)
|
|
26
|
+
NSLayoutConstraint.activate([
|
|
27
|
+
details.leadingAnchor.constraint(equalTo: container.leadingAnchor),
|
|
28
|
+
details.trailingAnchor.constraint(equalTo: container.trailingAnchor),
|
|
29
|
+
details.topAnchor.constraint(equalTo: container.topAnchor),
|
|
30
|
+
])
|
|
31
|
+
for hidden in [false, true, false] {
|
|
32
|
+
let current = try item(rich: true, hidden: hidden)
|
|
33
|
+
details.bind(current, theme: nil, fonts: NativeListFontFamilies())
|
|
34
|
+
container.layoutIfNeeded()
|
|
35
|
+
XCTAssertEqual(richVisual.isHidden, hidden)
|
|
36
|
+
XCTAssertEqual(richActions.directionalLayoutMargins.leading, hidden ? 0 : 52)
|
|
37
|
+
XCTAssertEqual(
|
|
38
|
+
NativeListActivityDetailsView.measure(
|
|
39
|
+
current.data, width: 390,
|
|
40
|
+
fonts: NativeListFontFamilies()),
|
|
41
|
+
ceil(details.frame.height) + 16, accuracy: 1)
|
|
42
|
+
func hasAmount(_ view: UIView) -> Bool {
|
|
43
|
+
if (view as? UILabel)?.text == "••••" { return true }
|
|
44
|
+
return view.subviews.contains(where: hasAmount)
|
|
45
|
+
}
|
|
46
|
+
XCTAssertTrue(hasAmount(details))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let cell = NativeListActivityCell(frame: CGRect(x: 0, y: 0, width: 390, height: 100))
|
|
50
|
+
let legacyVisual = try XCTUnwrap(cell.root.arrangedSubviews.first)
|
|
51
|
+
let column = try XCTUnwrap(cell.root.arrangedSubviews[1] as? UIStackView)
|
|
52
|
+
let legacyActions = try XCTUnwrap(column.arrangedSubviews.last as? UIStackView)
|
|
53
|
+
for hidden in [false, true, false] {
|
|
54
|
+
cell.bind(item: try item(rich: false, hidden: hidden), theme: nil,
|
|
55
|
+
layout: "linear", selected: false, checkboxState: { _, _, fallback in fallback },
|
|
56
|
+
fonts: NativeListFontFamilies())
|
|
57
|
+
XCTAssertEqual(legacyVisual.isHidden, hidden)
|
|
58
|
+
XCTAssertFalse(legacyActions.isHidden)
|
|
59
|
+
XCTAssertEqual((legacyActions.arrangedSubviews.first as? UIButton)?.currentTitle, "Speed up")
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
7
63
|
func testSmallNumberRunsPreserveBaselineAcrossAmountsFiatAndFee() throws {
|
|
8
64
|
func segments(_ prefix: String, _ suffix: String) -> [[String: Any]] {
|
|
9
65
|
[["text": prefix], ["text": "5", "style": "subscript"], ["text": suffix]]
|
|
@@ -41,6 +97,103 @@ final class NativeListActivityPresentationTests: XCTestCase {
|
|
|
41
97
|
}
|
|
42
98
|
}
|
|
43
99
|
|
|
100
|
+
func testTableColumnsStayStableAcrossFeeLeadingAndAmountReuseWithForcedRendererDirection() throws {
|
|
101
|
+
let width: CGFloat = 900
|
|
102
|
+
let horizontal: CGFloat = 16
|
|
103
|
+
let contentWidth = width - horizontal * 2
|
|
104
|
+
let gap: CGFloat = 12
|
|
105
|
+
let container = UIView(frame: CGRect(x: 0, y: 0, width: contentWidth, height: 4000))
|
|
106
|
+
let details = NativeListActivityDetailsView()
|
|
107
|
+
details.translatesAutoresizingMaskIntoConstraints = false
|
|
108
|
+
container.addSubview(details)
|
|
109
|
+
NSLayoutConstraint.activate([
|
|
110
|
+
details.leadingAnchor.constraint(equalTo: container.leadingAnchor),
|
|
111
|
+
details.trailingAnchor.constraint(equalTo: container.trailingAnchor),
|
|
112
|
+
details.topAnchor.constraint(equalTo: container.topAnchor),
|
|
113
|
+
])
|
|
114
|
+
let main = try XCTUnwrap(details.arrangedSubviews.first as? UIStackView)
|
|
115
|
+
let amounts = try XCTUnwrap(main.arrangedSubviews[2] as? UIStackView)
|
|
116
|
+
let fee = try XCTUnwrap(main.arrangedSubviews[3] as? UIStackView)
|
|
117
|
+
for rtl in [false, true] {
|
|
118
|
+
let direction: UIUserInterfaceLayoutDirection = rtl ? .rightToLeft : .leftToRight
|
|
119
|
+
// This fixture covers renderer geometry; App-level RTL propagation is separate.
|
|
120
|
+
func applyDirection(_ view: UIView) {
|
|
121
|
+
view.semanticContentAttribute = rtl ? .forceRightToLeft : .forceLeftToRight
|
|
122
|
+
view.subviews.forEach(applyDirection)
|
|
123
|
+
}
|
|
124
|
+
for hasFee in [true, false, true] {
|
|
125
|
+
var previousHeight: CGFloat = 0
|
|
126
|
+
for count in [1, 2, 6, 32] {
|
|
127
|
+
for hideLeading in [false, true, false] {
|
|
128
|
+
for feeKind in 0...2 {
|
|
129
|
+
var data: [String: Any] = [
|
|
130
|
+
"type": "activity", "key": "table", "title": "Send",
|
|
131
|
+
"description": "Contract interaction with a long description that wraps",
|
|
132
|
+
"leading": ["kind": "icon", "name": "ArrowTopOutline"],
|
|
133
|
+
"hideLeading": hideLeading,
|
|
134
|
+
"amounts": (0..<count).map { index in [
|
|
135
|
+
"key": "amount-\(index)", "text": index % 2 == 0 ? "-123456789012345678901234567890.123456789 ETH" : "+1 USDC",
|
|
136
|
+
"secondaryText": "$1,000.00",
|
|
137
|
+
"leading": ["kind": "icon", "name": "ArrowTopOutline"],
|
|
138
|
+
] as [String: Any] },
|
|
139
|
+
]
|
|
140
|
+
if hasFee {
|
|
141
|
+
data["fee"] = ["label": "Network fee",
|
|
142
|
+
"primary": feeKind == 1 ? "0.000000012345678 ETH" : "1 ETH",
|
|
143
|
+
"secondary": "$0.20", "hidden": feeKind == 2]
|
|
144
|
+
}
|
|
145
|
+
// Create amount views before applying the fixture direction; each transition binds once.
|
|
146
|
+
details.bind(try NativeListItem(data: data), theme: nil, fonts: NativeListFontFamilies())
|
|
147
|
+
applyDirection(details)
|
|
148
|
+
for presentation in ["table", "stacked", "table"] {
|
|
149
|
+
data["presentation"] = presentation
|
|
150
|
+
details.bind(try NativeListItem(data: data), theme: nil, fonts: NativeListFontFamilies())
|
|
151
|
+
XCTAssertEqual(main.effectiveUserInterfaceLayoutDirection, direction)
|
|
152
|
+
XCTAssertEqual(amounts.effectiveUserInterfaceLayoutDirection, direction)
|
|
153
|
+
XCTAssertEqual(fee.effectiveUserInterfaceLayoutDirection, direction)
|
|
154
|
+
container.setNeedsLayout()
|
|
155
|
+
container.layoutIfNeeded()
|
|
156
|
+
guard presentation == "table" else { continue }
|
|
157
|
+
let expected = (contentWidth - gap * (hasFee ? 2 : 1)) / (hasFee ? 2.6 : 2)
|
|
158
|
+
XCTAssertEqual(amounts.frame.width, expected, accuracy: 1)
|
|
159
|
+
let start = rtl ? contentWidth - expected * 2 - gap : expected + gap
|
|
160
|
+
XCTAssertEqual(amounts.frame.minX, start, accuracy: 1)
|
|
161
|
+
XCTAssertEqual(amounts.frame.midX, start + expected / 2, accuracy: 1)
|
|
162
|
+
XCTAssertEqual(amounts.arrangedSubviews.count, count)
|
|
163
|
+
for amount in amounts.arrangedSubviews {
|
|
164
|
+
XCTAssertEqual(amount.frame.minX, 0, accuracy: 1)
|
|
165
|
+
XCTAssertEqual(amount.frame.width, expected, accuracy: 1)
|
|
166
|
+
let row = try XCTUnwrap(amount as? UIStackView)
|
|
167
|
+
let leading = row.arrangedSubviews[0]
|
|
168
|
+
let labels = row.arrangedSubviews[1]
|
|
169
|
+
if rtl { XCTAssertLessThanOrEqual(labels.frame.maxX, leading.frame.minX) }
|
|
170
|
+
else { XCTAssertLessThanOrEqual(leading.frame.maxX, labels.frame.minX) }
|
|
171
|
+
XCTAssertGreaterThanOrEqual(labels.frame.minX, 0)
|
|
172
|
+
XCTAssertLessThanOrEqual(labels.frame.maxX, amount.frame.width + 1)
|
|
173
|
+
}
|
|
174
|
+
if hasFee {
|
|
175
|
+
XCTAssertEqual(fee.frame.width, expected * 0.6, accuracy: 1)
|
|
176
|
+
XCTAssertEqual(fee.alpha, feeKind == 2 ? 0 : 1)
|
|
177
|
+
for child in fee.arrangedSubviews {
|
|
178
|
+
XCTAssertGreaterThanOrEqual(child.frame.minX, -1)
|
|
179
|
+
XCTAssertLessThanOrEqual(child.frame.maxX, fee.frame.width + 1)
|
|
180
|
+
if rtl { XCTAssertEqual(child.frame.minX, 0, accuracy: 1) }
|
|
181
|
+
else { XCTAssertEqual(child.frame.maxX, fee.frame.width, accuracy: 1) }
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
XCTAssertEqual(
|
|
185
|
+
NativeListActivityDetailsView.measure(data, width: width, fonts: NativeListFontFamilies()),
|
|
186
|
+
ceil(details.frame.height) + 16, accuracy: 1)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
XCTAssertGreaterThan(details.frame.height, previousHeight)
|
|
191
|
+
previousHeight = details.frame.height
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
44
197
|
func testAutomaticHeightMatchesRenderedStacks() throws {
|
|
45
198
|
let amount: [String: Any] = ["key": "send", "text": "-0.5 ETH", "secondaryText": "$1,000.00"]
|
|
46
199
|
let cases: [(String, [String: Any])] = [
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
import XCTest
|
|
3
|
+
@testable import NativeListModule
|
|
4
|
+
|
|
5
|
+
@MainActor
|
|
6
|
+
final class NativeListIdentityTitleIconLayoutTests: XCTestCase {
|
|
7
|
+
private func child<T>(_ cell: NativeListIdentityCell, _ label: String, as type: T.Type) throws -> T {
|
|
8
|
+
try XCTUnwrap(Mirror(reflecting: cell).children.first { $0.label == label }?.value as? T)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// OK-66041: the Home native-token row carries a GasSolid `titleIcon`. The
|
|
12
|
+
// glyph must sit right after the title text (4pt gap), as Android's
|
|
13
|
+
// PackedTitleLineLayout and the Web flex row already do. iOS let the title
|
|
14
|
+
// label stretch across the whole title row, so the icon landed next to the
|
|
15
|
+
// trailing value column instead of beside "ETH".
|
|
16
|
+
func testTitleIconFollowsTheTitleTextInsteadOfTheRowEnd() throws {
|
|
17
|
+
let cell = NativeListIdentityCell(frame: CGRect(x: 0, y: 0, width: 390, height: 60))
|
|
18
|
+
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 390, height: 200))
|
|
19
|
+
window.addSubview(cell)
|
|
20
|
+
let titleIcon = try child(cell, "titleIconView", as: UIImageView.self)
|
|
21
|
+
let titleLabel = try child(cell, "titleLabel", as: UILabel.self)
|
|
22
|
+
let titleStack = try child(cell, "titleRowStack", as: UIStackView.self)
|
|
23
|
+
let item = try NativeListItem(data: [
|
|
24
|
+
"key": "eth", "type": "identity", "title": "ETH", "height": 60,
|
|
25
|
+
"leading": ["kind": "token", "fallbackIcon": ["name": "CryptoCoinOutline"]],
|
|
26
|
+
"titleIcon": ["name": "GasSolid"],
|
|
27
|
+
"subtitleSegments": [
|
|
28
|
+
["text": "$2,330.23", "tone": "secondary"],
|
|
29
|
+
["text": "+0.23%", "tone": "positive", "separatorBefore": true],
|
|
30
|
+
],
|
|
31
|
+
"trailing": [["kind": "valuePair", "primary": "0.00001417", "secondary": "$0.03"]],
|
|
32
|
+
])
|
|
33
|
+
cell.bind(item: item, theme: nil, layout: "linear", selected: false,
|
|
34
|
+
checkboxState: { _, _, fallback in fallback }, fonts: NativeListFontFamilies())
|
|
35
|
+
cell.layoutIfNeeded()
|
|
36
|
+
|
|
37
|
+
XCTAssertFalse(titleIcon.isHidden)
|
|
38
|
+
// The title keeps its intrinsic width; the slack goes to the end of the row.
|
|
39
|
+
XCTAssertEqual(
|
|
40
|
+
titleLabel.bounds.width, titleLabel.intrinsicContentSize.width, accuracy: 1,
|
|
41
|
+
"title label must not stretch across the title row")
|
|
42
|
+
let labelFrame = titleLabel.convert(titleLabel.bounds, to: cell)
|
|
43
|
+
let iconFrame = titleIcon.convert(titleIcon.bounds, to: cell)
|
|
44
|
+
XCTAssertEqual(iconFrame.minX, labelFrame.maxX + 4, accuracy: 1,
|
|
45
|
+
"gas icon must follow the title text with the 4pt gap")
|
|
46
|
+
let iconInRow = titleIcon.convert(titleIcon.bounds, to: titleStack)
|
|
47
|
+
XCTAssertLessThan(iconInRow.maxX, titleStack.bounds.width / 2,
|
|
48
|
+
"gas icon must stay in the leading half of the title row, not at the value column")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// A long title still truncates in front of the icon instead of pushing it
|
|
52
|
+
// out of the row, and the badge keeps following the icon.
|
|
53
|
+
func testLongTitleTruncatesAndKeepsIconAndBadgeAdjacent() throws {
|
|
54
|
+
let cell = NativeListIdentityCell(frame: CGRect(x: 0, y: 0, width: 320, height: 60))
|
|
55
|
+
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 200))
|
|
56
|
+
window.addSubview(cell)
|
|
57
|
+
let titleIcon = try child(cell, "titleIconView", as: UIImageView.self)
|
|
58
|
+
let titleLabel = try child(cell, "titleLabel", as: UILabel.self)
|
|
59
|
+
let badge = try child(cell, "badgeLabel", as: UILabel.self)
|
|
60
|
+
let item = try NativeListItem(data: [
|
|
61
|
+
"key": "long", "type": "identity",
|
|
62
|
+
"title": "A very long token name that cannot possibly fit on one line", "height": 60,
|
|
63
|
+
"leading": ["kind": "token", "fallbackIcon": ["name": "CryptoCoinOutline"]],
|
|
64
|
+
"titleIcon": ["name": "GasSolid"],
|
|
65
|
+
"badges": [["key": "native", "text": "Native"]],
|
|
66
|
+
"trailing": [["kind": "valuePair", "primary": "1.00", "secondary": "$1.00"]],
|
|
67
|
+
])
|
|
68
|
+
cell.bind(item: item, theme: nil, layout: "linear", selected: false,
|
|
69
|
+
checkboxState: { _, _, fallback in fallback }, fonts: NativeListFontFamilies())
|
|
70
|
+
cell.layoutIfNeeded()
|
|
71
|
+
|
|
72
|
+
let labelFrame = titleLabel.convert(titleLabel.bounds, to: cell)
|
|
73
|
+
let iconFrame = titleIcon.convert(titleIcon.bounds, to: cell)
|
|
74
|
+
let badgeFrame = badge.convert(badge.bounds, to: cell)
|
|
75
|
+
XCTAssertEqual(titleIcon.bounds.width, 20, accuracy: 0.5)
|
|
76
|
+
XCTAssertEqual(iconFrame.minX, labelFrame.maxX + 4, accuracy: 1)
|
|
77
|
+
XCTAssertFalse(badge.isHidden)
|
|
78
|
+
XCTAssertGreaterThan(badgeFrame.minX, iconFrame.maxX)
|
|
79
|
+
XCTAssertLessThanOrEqual(badgeFrame.maxX, cell.bounds.width)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
import XCTest
|
|
3
|
+
@testable import NativeListModule
|
|
4
|
+
|
|
5
|
+
@MainActor
|
|
6
|
+
final class NativeListLeadingVisualPairBackdropTests: XCTestCase {
|
|
7
|
+
private func child<T>(_ visual: NativeListLeadingVisual, _ label: String, as type: T.Type) throws -> T {
|
|
8
|
+
try XCTUnwrap(Mirror(reflecting: visual).children.first { $0.label == label }?.value as? T)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
private func token(_ uri: String) -> [String: Any] {
|
|
12
|
+
[
|
|
13
|
+
"kind": "token", "shape": "circle",
|
|
14
|
+
"image": ["uri": uri, "width": 40, "height": 40],
|
|
15
|
+
"fallbackIcon": ["name": "CryptoCoinOutline"],
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// PR #185 review: the pair ring sits above the primary token. While the
|
|
20
|
+
// secondary image has not loaded (or failed), its slot is hidden, so the ring
|
|
21
|
+
// must be hidden too; otherwise a blank row-background disc covers the
|
|
22
|
+
// primary's lower-right corner.
|
|
23
|
+
func testPairRingStaysHiddenWhileTheSecondaryImageIsNotDisplayed() throws {
|
|
24
|
+
let visual = NativeListLeadingVisual(frame: CGRect(x: 0, y: 0, width: 40, height: 40))
|
|
25
|
+
let ring = try child(visual, "pairBackdrop", as: UIView.self)
|
|
26
|
+
visual.bind(
|
|
27
|
+
token("https://example.invalid/primary.png"), style: [:], key: "pair", theme: nil,
|
|
28
|
+
isUnread: false, secondaryVisual: token("https://example.invalid/secondary.png"),
|
|
29
|
+
fonts: NativeListFontFamilies())
|
|
30
|
+
visual.layoutIfNeeded()
|
|
31
|
+
// `slots` is a value-type array: read it after bind has created the slots.
|
|
32
|
+
let slots = try child(visual, "slots", as: [NativeListImageSlot].self)
|
|
33
|
+
XCTAssertEqual(slots.count, 2)
|
|
34
|
+
XCTAssertTrue(slots[1].view.isHidden, "secondary slot is hidden until its image loads")
|
|
35
|
+
XCTAssertTrue(ring.isHidden, "ring must follow the hidden secondary slot")
|
|
36
|
+
|
|
37
|
+
visual.recycle()
|
|
38
|
+
XCTAssertTrue(ring.isHidden)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
func testNoPairMeansNoRing() throws {
|
|
42
|
+
let visual = NativeListLeadingVisual(frame: CGRect(x: 0, y: 0, width: 40, height: 40))
|
|
43
|
+
let ring = try child(visual, "pairBackdrop", as: UIView.self)
|
|
44
|
+
visual.bind(
|
|
45
|
+
token("https://example.invalid/primary.png"), style: [:], key: "single", theme: nil,
|
|
46
|
+
isUnread: false, fonts: NativeListFontFamilies())
|
|
47
|
+
visual.layoutIfNeeded()
|
|
48
|
+
XCTAssertTrue(ring.isHidden)
|
|
49
|
+
}
|
|
50
|
+
}
|