@onekeyfe/react-native-native-list 6.7.0-alpha.354 → 6.7.0-alpha.362
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 +0 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +7 -240
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +4 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +3 -6
- package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +0 -12
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +7 -87
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +1 -135
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +14 -43
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +0 -25
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +2 -17
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +0 -22
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +0 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +0 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +2 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +0 -69
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +1 -55
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +21 -585
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +0 -1
- package/docs/ROW_TEMPLATES.md +9 -60
- package/docs/SPEC.md +5 -317
- package/docs/STYLE_SPEC.md +0 -6
- package/ios/HybridNativeList.swift +0 -10
- package/ios/NativeListAccessoryStack.swift +37 -220
- package/ios/NativeListActivityDetailsView.swift +8 -18
- package/ios/NativeListActivityRenderer.swift +2 -8
- package/ios/NativeListDataRowRenderer.swift +8 -105
- package/ios/NativeListDesignAssets.swift +0 -3
- package/ios/NativeListIdentityRenderer.swift +4 -119
- package/ios/NativeListLeadingVisual.swift +14 -49
- package/ios/NativeListMessageRenderer.swift +1 -34
- package/ios/NativeListModels.swift +2 -16
- package/ios/NativeListRendererRegistry.swift +0 -1
- package/ios/NativeListResolvedText.swift +1 -2
- package/ios/NativeListRowHost.swift +0 -14
- package/ios/NativeListSectionHeaderRenderer.swift +0 -88
- package/ios/RNCNativeListView.swift +29 -331
- package/ios/tests/NativeListActivityPresentationTests.swift +0 -56
- package/ios/tests/NativeListLifecycleTests.swift +3 -890
- package/lib/module/NativeList.js +21 -39
- package/lib/module/NativeList.web.js +4 -51
- package/lib/module/models.js +0 -1
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +8 -320
- package/lib/module/web/NativeListWebEngine.js +18 -373
- package/lib/module/web/templates/ActivityRowRenderer.js +7 -8
- package/lib/module/web/templates/DataRowRenderer.js +5 -40
- package/lib/module/web/templates/IdentityRowRenderer.js +4 -90
- package/lib/module/web/templates/MessageRowRenderer.js +2 -18
- package/lib/module/web/templates/RowContainerStyle.js +0 -1
- package/lib/module/web/templates/RowRendererRegistry.js +0 -3
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +2 -36
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +0 -9
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +0 -2
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +0 -5
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +0 -6
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +0 -7
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +0 -6
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +0 -1
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +0 -11
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +0 -2
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +0 -2
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +0 -2
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +0 -3
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +0 -1
- package/lib/typescript/src/NativeList.nitro.d.ts +0 -1
- package/lib/typescript/src/NativeList.types.d.ts +0 -8
- package/lib/typescript/src/models.d.ts +9 -101
- package/lib/typescript/src/validation.d.ts +0 -10
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +0 -26
- package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +3 -9
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +0 -9
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +0 -2
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +0 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +0 -6
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +0 -7
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +0 -6
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +0 -1
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +0 -11
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +0 -2
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +0 -2
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +0 -2
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +0 -3
- package/nitrogen/generated/shared/json/NativeListConfig.json +0 -1
- package/package.json +3 -3
- package/react-native-native-list.podspec +0 -1
- package/src/NativeList.nitro.ts +0 -1
- package/src/NativeList.tsx +24 -72
- package/src/NativeList.types.ts +0 -9
- package/src/NativeList.web.tsx +8 -72
- package/src/models.ts +3 -113
- package/src/selection.ts +0 -1
- package/src/validation.ts +6 -721
- package/src/web/NativeListWebEngine.ts +19 -568
- package/src/web/templates/ActivityRowRenderer.ts +6 -14
- package/src/web/templates/DataRowRenderer.ts +20 -93
- package/src/web/templates/IdentityRowRenderer.ts +5 -150
- package/src/web/templates/MessageRowRenderer.ts +7 -23
- package/src/web/templates/RowContainerStyle.ts +0 -2
- package/src/web/templates/RowRendererRegistry.ts +1 -11
- package/src/web/templates/SectionHeaderRowRenderer.ts +4 -47
- package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +0 -102
- package/ios/NativeListButtonGroupRenderer.swift +0 -89
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +0 -4
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +0 -3
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +0 -3
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +0 -47
- package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +0 -14
- package/src/web/templates/ButtonGroupRowRenderer.ts +0 -58
|
@@ -3,72 +3,12 @@ import UIKit
|
|
|
3
3
|
// OneKey patch: explicit summary actions use the source text's physical-pixel line box.
|
|
4
4
|
final class NativeListAccessoryButton: UIButton {
|
|
5
5
|
var pressedBackgroundColor: UIColor?
|
|
6
|
-
var normalBackgroundColor: UIColor = .clear
|
|
7
|
-
var fixedTextLineHeight: CGFloat?
|
|
8
6
|
var rowTextOffsetY: CGFloat = 0
|
|
9
|
-
var helpBindingGeneration = 0
|
|
10
|
-
private var helpTrackingGeneration = 0
|
|
11
|
-
override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
|
|
12
|
-
helpTrackingGeneration = helpBindingGeneration
|
|
13
|
-
return super.beginTracking(touch, with: event)
|
|
14
|
-
}
|
|
15
|
-
override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
|
|
16
|
-
guard helpTrackingGeneration == helpBindingGeneration else {
|
|
17
|
-
cancelTracking(with: event)
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
super.endTracking(touch, with: event)
|
|
21
|
-
}
|
|
22
|
-
var helpPrimaryLineOnly = false
|
|
23
|
-
var showsHelpUnderline = false
|
|
24
|
-
let helpAnchor = UIView()
|
|
25
|
-
private let helpUnderline = CAShapeLayer()
|
|
26
|
-
|
|
27
|
-
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
|
28
|
-
if helpPrimaryLineOnly { return helpAnchor.frame.contains(point) }
|
|
29
|
-
return super.point(inside: point, with: event)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
private func layoutHelp() {
|
|
33
|
-
guard helpPrimaryLineOnly || showsHelpUnderline else {
|
|
34
|
-
helpUnderline.isHidden = true
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
guard let titleLabel else { return }
|
|
38
|
-
if helpAnchor.superview == nil {
|
|
39
|
-
helpAnchor.isUserInteractionEnabled = false
|
|
40
|
-
helpAnchor.isAccessibilityElement = false
|
|
41
|
-
addSubview(helpAnchor)
|
|
42
|
-
helpUnderline.fillColor = UIColor.clear.cgColor
|
|
43
|
-
helpUnderline.lineWidth = 1
|
|
44
|
-
helpUnderline.lineDashPattern = [3, 2]
|
|
45
|
-
helpAnchor.layer.addSublayer(helpUnderline)
|
|
46
|
-
}
|
|
47
|
-
var frame = titleLabel.frame
|
|
48
|
-
if helpPrimaryLineOnly, let text = attributedTitle(for: .normal) {
|
|
49
|
-
let range = (text.string as NSString).range(of: "\n")
|
|
50
|
-
let primary = text.attributedSubstring(from: NSRange(location: 0, length: range.location == NSNotFound ? text.length : range.location))
|
|
51
|
-
let width = min(frame.width, ceil(primary.size().width))
|
|
52
|
-
frame.origin.x += frame.width - width
|
|
53
|
-
frame.size.width = width
|
|
54
|
-
let paragraph = primary.length > 0 ? primary.attribute(.paragraphStyle, at: 0, effectiveRange: nil) as? NSParagraphStyle : nil
|
|
55
|
-
frame.size.height = paragraph?.minimumLineHeight ?? 20
|
|
56
|
-
}
|
|
57
|
-
helpAnchor.frame = frame
|
|
58
|
-
let text = attributedTitle(for: .normal)
|
|
59
|
-
let color = text.flatMap { $0.length > 0 ? $0.attribute(.foregroundColor, at: 0, effectiveRange: nil) as? UIColor : nil }
|
|
60
|
-
helpUnderline.strokeColor = (color ?? titleColor(for: .normal))?.cgColor
|
|
61
|
-
helpUnderline.isHidden = !showsHelpUnderline
|
|
62
|
-
let path = UIBezierPath()
|
|
63
|
-
path.move(to: CGPoint(x: 0, y: frame.height - 1))
|
|
64
|
-
path.addLine(to: CGPoint(x: frame.width, y: frame.height - 1))
|
|
65
|
-
helpUnderline.path = path.cgPath
|
|
66
|
-
}
|
|
67
7
|
|
|
68
8
|
override var isHighlighted: Bool {
|
|
69
9
|
didSet {
|
|
70
10
|
guard let pressedBackgroundColor else { return }
|
|
71
|
-
backgroundColor = isHighlighted ? pressedBackgroundColor :
|
|
11
|
+
backgroundColor = isHighlighted ? pressedBackgroundColor : .clear
|
|
72
12
|
}
|
|
73
13
|
}
|
|
74
14
|
|
|
@@ -112,11 +52,6 @@ final class NativeListAccessoryButton: UIButton {
|
|
|
112
52
|
|
|
113
53
|
override var intrinsicContentSize: CGSize {
|
|
114
54
|
var size = super.intrinsicContentSize
|
|
115
|
-
if let fixedTextLineHeight {
|
|
116
|
-
size.width += 2
|
|
117
|
-
size.height = fixedTextLineHeight + contentEdgeInsets.top + contentEdgeInsets.bottom + 2
|
|
118
|
-
return size
|
|
119
|
-
}
|
|
120
55
|
guard selectorSummaryLineHeight != nil || marketLineHeight != nil,
|
|
121
56
|
let title = attributedTitle(for: .normal)
|
|
122
57
|
else { return size }
|
|
@@ -136,10 +71,6 @@ final class NativeListAccessoryButton: UIButton {
|
|
|
136
71
|
defer {
|
|
137
72
|
if let titleLabel {
|
|
138
73
|
var frame = titleLabel.frame
|
|
139
|
-
if let fixedTextLineHeight {
|
|
140
|
-
frame.size.height = fixedTextLineHeight
|
|
141
|
-
frame.origin.y = (bounds.height - fixedTextLineHeight) / 2
|
|
142
|
-
}
|
|
143
74
|
if contentVerticalAlignment == .top {
|
|
144
75
|
frame.origin.y = contentEdgeInsets.top
|
|
145
76
|
} else if contentVerticalAlignment == .bottom {
|
|
@@ -148,7 +79,6 @@ final class NativeListAccessoryButton: UIButton {
|
|
|
148
79
|
frame.origin.y += rowTextOffsetY
|
|
149
80
|
titleLabel.frame = frame
|
|
150
81
|
}
|
|
151
|
-
layoutHelp()
|
|
152
82
|
}
|
|
153
83
|
if let lineHeight = marketLineHeight, let titleLabel, let title = attributedTitle(for: .normal)
|
|
154
84
|
{
|
|
@@ -197,8 +127,6 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
197
127
|
private var boundCheckboxData: [String: Any]?
|
|
198
128
|
private var boundCheckboxTarget: NativeSelectionTarget?
|
|
199
129
|
private var semanticValueButtons: [UIButton] = []
|
|
200
|
-
private var valuePairSubscriptRanges: [ObjectIdentifier: [(NSRange, Bool)]] = [:]
|
|
201
|
-
private var tertiaryIconButtons: Set<ObjectIdentifier> = []
|
|
202
130
|
private var accessorySizeConstraints: [NSLayoutConstraint] = []
|
|
203
131
|
private var currentItem: NativeListItem?
|
|
204
132
|
private var currentTheme: [String: Any]?
|
|
@@ -282,19 +210,14 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
282
210
|
}
|
|
283
211
|
}
|
|
284
212
|
func anchorInset(for view: UIView) -> CGFloat {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
if tertiaryIconButtons.contains(ObjectIdentifier(view)) { return 7 }
|
|
289
|
-
return currentItem?.data.string("presentation") == "accountSelector" ? 7 : 0
|
|
213
|
+
currentItem?.data.string("presentation") == "accountSelector"
|
|
214
|
+
&& accessoryButtons.contains { $0 === view } && view.bounds.width == 38 ? 7 : 0
|
|
290
215
|
}
|
|
291
216
|
func reset() {
|
|
292
217
|
NSLayoutConstraint.deactivate(accessorySizeConstraints)
|
|
293
218
|
accessorySizeConstraints.removeAll()
|
|
294
219
|
accessoryActions.removeAll()
|
|
295
220
|
semanticValueButtons.removeAll()
|
|
296
|
-
valuePairSubscriptRanges.removeAll()
|
|
297
|
-
tertiaryIconButtons.removeAll()
|
|
298
221
|
checkboxAction = nil
|
|
299
222
|
boundCheckboxData = nil
|
|
300
223
|
boundCheckboxTarget = nil
|
|
@@ -302,7 +225,6 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
302
225
|
contentGap = nil
|
|
303
226
|
currentItem = nil
|
|
304
227
|
for (index, button) in accessoryButtons.enumerated() {
|
|
305
|
-
button.tag = index
|
|
306
228
|
button.setAttributedTitle(nil, for: .normal)
|
|
307
229
|
button.setTitle(nil, for: .normal)
|
|
308
230
|
button.setImage(nil, for: .normal)
|
|
@@ -314,23 +236,14 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
314
236
|
button.contentHorizontalAlignment = .center
|
|
315
237
|
button.contentVerticalAlignment = .center
|
|
316
238
|
button.rowTextOffsetY = 0
|
|
317
|
-
button.helpBindingGeneration += 1
|
|
318
|
-
button.helpPrimaryLineOnly = false
|
|
319
|
-
button.showsHelpUnderline = false
|
|
320
239
|
button.transform = .identity
|
|
321
240
|
button.marketLineHeight = nil
|
|
322
241
|
button.selectorSummaryLineHeight = nil
|
|
323
242
|
button.backgroundColor = .clear
|
|
324
243
|
button.pressedBackgroundColor = nil
|
|
325
|
-
button.normalBackgroundColor = .clear
|
|
326
|
-
button.fixedTextLineHeight = nil
|
|
327
|
-
button.contentEdgeInsets = .zero
|
|
328
|
-
button.layer.borderWidth = 0
|
|
329
|
-
button.layer.borderColor = nil
|
|
330
244
|
button.layer.cornerRadius = 0
|
|
331
245
|
button.isHidden = true
|
|
332
246
|
button.isEnabled = true
|
|
333
|
-
button.isUserInteractionEnabled = true
|
|
334
247
|
button.alpha = 1
|
|
335
248
|
button.accessibilityIdentifier = nil
|
|
336
249
|
button.accessibilityLabel = nil
|
|
@@ -340,13 +253,9 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
340
253
|
spinner.alpha = 1
|
|
341
254
|
}
|
|
342
255
|
@objc private func pressed(_ button: UIButton) {
|
|
343
|
-
guard
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if !action.0.isEmpty {
|
|
347
|
-
let anchor = accessoryButtons[controlIndex]
|
|
348
|
-
onAction?(action.0, anchor.helpPrimaryLineOnly ? anchor.helpAnchor : button, button.tag, action.1)
|
|
349
|
-
}
|
|
256
|
+
guard accessoryActions.indices.contains(button.tag) else { return }
|
|
257
|
+
let action = accessoryActions[button.tag]
|
|
258
|
+
if !action.0.isEmpty { onAction?(action.0, button, button.tag, action.1) }
|
|
350
259
|
}
|
|
351
260
|
@objc private func checkboxPressed() {
|
|
352
261
|
if let action = checkboxAction { onAction?(action.0, checkboxButton, nil, action.1) }
|
|
@@ -358,42 +267,8 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
358
267
|
_ checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
359
268
|
) {
|
|
360
269
|
var textIndex = 0
|
|
361
|
-
for
|
|
362
|
-
let controlIndex = textIndex
|
|
270
|
+
for accessory in accessories.prefix(2) {
|
|
363
271
|
switch accessory.string("kind") {
|
|
364
|
-
case "button":
|
|
365
|
-
showAccessory(
|
|
366
|
-
textIndex, accessory.string("label"),
|
|
367
|
-
action: accessory.bool("disabled") || item.data.bool("disabled")
|
|
368
|
-
? nil : (accessory.string("actionKey"), nil))
|
|
369
|
-
let button = accessoryButtons[textIndex]
|
|
370
|
-
button.titleLabel?.font = nativeListFont(ofSize: 14, weight: .medium, fonts: fonts)
|
|
371
|
-
button.fixedTextLineHeight = 20
|
|
372
|
-
button.contentEdgeInsets = UIEdgeInsets(top: 4, left: 10, bottom: 4, right: 10)
|
|
373
|
-
button.layer.borderWidth = 1
|
|
374
|
-
button.layer.borderColor = UIColor.clear.cgColor
|
|
375
|
-
button.layer.cornerRadius = 15
|
|
376
|
-
button.backgroundColor = UIColor(
|
|
377
|
-
nativeListHex: accessory.string("backgroundColor",
|
|
378
|
-
default: theme?["strongBackground"] as? String ?? "#F0F0F0"),
|
|
379
|
-
fallback: .clear)
|
|
380
|
-
button.normalBackgroundColor = button.backgroundColor ?? .clear
|
|
381
|
-
button.pressedBackgroundColor = UIColor(
|
|
382
|
-
nativeListHex: accessory.string("pressedBackgroundColor",
|
|
383
|
-
default: theme?["rowPressedBackground"] as? String ?? "#E4E4E4"),
|
|
384
|
-
fallback: .clear)
|
|
385
|
-
button.setTitleColor(
|
|
386
|
-
UIColor(
|
|
387
|
-
nativeListHex: accessory.string("textColor",
|
|
388
|
-
default: theme?["primaryText"] as? String ?? "#202020"),
|
|
389
|
-
fallback: .darkGray),
|
|
390
|
-
for: .normal)
|
|
391
|
-
button.accessibilityIdentifier = accessory.string("testID")
|
|
392
|
-
button.accessibilityLabel =
|
|
393
|
-
accessory.string("accessibilityLabel", default: accessory.string("label"))
|
|
394
|
-
button.isEnabled = !item.data.bool("disabled") && !accessory.bool("disabled")
|
|
395
|
-
button.alpha = button.isEnabled ? 1 : 0.4
|
|
396
|
-
textIndex += 1
|
|
397
272
|
case "value":
|
|
398
273
|
showAccessory(textIndex, accessory.string("text"))
|
|
399
274
|
semanticValueButtons.append(accessoryButtons[textIndex])
|
|
@@ -450,7 +325,6 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
450
325
|
textIndex += 1
|
|
451
326
|
default: break
|
|
452
327
|
}
|
|
453
|
-
if textIndex > controlIndex { accessoryButtons[controlIndex].tag = slot }
|
|
454
328
|
}
|
|
455
329
|
}
|
|
456
330
|
|
|
@@ -531,12 +405,8 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
531
405
|
theme: [String: Any]?
|
|
532
406
|
) {
|
|
533
407
|
guard accessoryButtons.indices.contains(index) else { return }
|
|
534
|
-
let
|
|
535
|
-
let
|
|
536
|
-
let primary = primarySegments.isEmpty
|
|
537
|
-
? accessory.string("primary") : primarySegments.map { $0.string("text") }.joined()
|
|
538
|
-
let secondary = secondarySegments.isEmpty
|
|
539
|
-
? accessory.string("secondary") : secondarySegments.map { $0.string("text") }.joined()
|
|
408
|
+
let primary = accessory.string("primary")
|
|
409
|
+
let secondary = accessory.string("secondary")
|
|
540
410
|
guard !primary.isEmpty || !secondary.isEmpty else { return }
|
|
541
411
|
let button = accessoryButtons[index]
|
|
542
412
|
let text = NSMutableAttributedString()
|
|
@@ -544,66 +414,45 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
544
414
|
primaryParagraph.alignment = .right
|
|
545
415
|
primaryParagraph.minimumLineHeight = 20
|
|
546
416
|
primaryParagraph.maximumLineHeight = 20
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
417
|
+
text.append(
|
|
418
|
+
NSAttributedString(
|
|
419
|
+
string: primary,
|
|
420
|
+
attributes: [
|
|
421
|
+
.font: nativeListFont(ofSize: 16, weight: .medium, fonts: fonts),
|
|
422
|
+
.foregroundColor: accessoryTextColor(
|
|
423
|
+
accessory.string("primaryTone"),
|
|
424
|
+
defaultTone: "primary",
|
|
425
|
+
theme: theme
|
|
426
|
+
),
|
|
427
|
+
.paragraphStyle: primaryParagraph,
|
|
428
|
+
]
|
|
429
|
+
))
|
|
553
430
|
if !primary.isEmpty, !secondary.isEmpty { text.append(NSAttributedString(string: "\n")) }
|
|
554
431
|
let secondaryParagraph = NSMutableParagraphStyle()
|
|
555
432
|
secondaryParagraph.alignment = .right
|
|
556
433
|
secondaryParagraph.minimumLineHeight = 20
|
|
557
434
|
secondaryParagraph.maximumLineHeight = 20
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
435
|
+
text.append(
|
|
436
|
+
NSAttributedString(
|
|
437
|
+
string: secondary,
|
|
438
|
+
attributes: [
|
|
439
|
+
.font: nativeListFont(ofSize: 14, fonts: fonts),
|
|
440
|
+
.foregroundColor: accessoryTextColor(
|
|
441
|
+
accessory.string("secondaryTone"),
|
|
442
|
+
defaultTone: "secondary",
|
|
443
|
+
theme: theme
|
|
444
|
+
),
|
|
445
|
+
.paragraphStyle: secondaryParagraph,
|
|
446
|
+
]
|
|
447
|
+
))
|
|
563
448
|
button.isHidden = false
|
|
564
449
|
button.titleLabel?.numberOfLines = 2
|
|
565
450
|
button.contentHorizontalAlignment = .trailing
|
|
566
451
|
button.setAttributedTitle(text, for: .normal)
|
|
567
|
-
valuePairSubscriptRanges[ObjectIdentifier(button)] = subscriptRanges
|
|
568
452
|
button.setContentHuggingPriority(.required, for: .horizontal)
|
|
569
453
|
button.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
570
454
|
while accessoryActions.count <= index { accessoryActions.append(("", nil)) }
|
|
571
455
|
accessoryActions[index] = ("", nil)
|
|
572
|
-
if let help = accessory.dictionary("primaryHelp") {
|
|
573
|
-
button.helpPrimaryLineOnly = true
|
|
574
|
-
button.showsHelpUnderline = help.string("underline") == "dashed"
|
|
575
|
-
button.isUserInteractionEnabled = help.string("presentation") == "popover"
|
|
576
|
-
accessoryActions[index] = (help.string("presentation") == "popover" ? help.string("actionKey") : "", nil)
|
|
577
|
-
button.setNeedsLayout()
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
private func appendValuePairLine(
|
|
582
|
-
to text: NSMutableAttributedString,
|
|
583
|
-
fallback: String,
|
|
584
|
-
segments: [[String: Any]],
|
|
585
|
-
fontSize: CGFloat,
|
|
586
|
-
weight: NativeListFontWeight,
|
|
587
|
-
color: UIColor,
|
|
588
|
-
paragraph: NSParagraphStyle,
|
|
589
|
-
isPrimary: Bool,
|
|
590
|
-
subscriptRanges: inout [(NSRange, Bool)]
|
|
591
|
-
) {
|
|
592
|
-
let runs = segments.isEmpty ? [["text": fallback]] : segments
|
|
593
|
-
for run in runs {
|
|
594
|
-
let content = run.string("text")
|
|
595
|
-
let isSubscript = run.string("style") == "subscript"
|
|
596
|
-
let start = text.length
|
|
597
|
-
text.append(NSAttributedString(string: content, attributes: [
|
|
598
|
-
.font: nativeListFont(
|
|
599
|
-
ofSize: isSubscript ? ceil(fontSize * 0.6) : fontSize, weight: weight, fonts: fonts),
|
|
600
|
-
.foregroundColor: color,
|
|
601
|
-
.paragraphStyle: paragraph,
|
|
602
|
-
]))
|
|
603
|
-
if isSubscript && text.length > start {
|
|
604
|
-
subscriptRanges.append((NSRange(location: start, length: text.length - start), isPrimary))
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
456
|
}
|
|
608
457
|
|
|
609
458
|
private func showMenuAccessory(
|
|
@@ -651,12 +500,7 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
651
500
|
? nativeListColor(currentTheme, "iconSubdued", "#8D8D8D")
|
|
652
501
|
: UIColor(nativeListHex: data.string("tintColor", default: "#646464"), fallback: .darkGray)
|
|
653
502
|
button.tintColor = tintColor
|
|
654
|
-
let
|
|
655
|
-
data.string("name") == "RefreshCcwOutline" && data.string("actionKey").isEmpty
|
|
656
|
-
let image = isDecorativeRefresh
|
|
657
|
-
? nativeListIcon(named: data.string("name"), size: CGSize(width: 16, height: 16))
|
|
658
|
-
: nativeListIcon(named: data.string("name"))
|
|
659
|
-
if let image {
|
|
503
|
+
if let image = nativeListIcon(named: data.string("name")) {
|
|
660
504
|
button.setImage(image, for: .normal)
|
|
661
505
|
button.setImage(
|
|
662
506
|
image.withTintColor(tintColor, renderingMode: .alwaysOriginal),
|
|
@@ -664,22 +508,8 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
664
508
|
)
|
|
665
509
|
}
|
|
666
510
|
let isDrillIn = data.string("kind") == "chevron"
|
|
667
|
-
let isTertiary = data.string("buttonStyle") == "tertiary"
|
|
668
|
-
if data.string("kind") == "icon" && isTertiary {
|
|
669
|
-
tertiaryIconButtons.insert(ObjectIdentifier(button))
|
|
670
|
-
}
|
|
671
511
|
let isAccountIcon = currentItem?.data.string("presentation") == "accountSelector" && !isDrillIn
|
|
672
|
-
|
|
673
|
-
let size: CGFloat =
|
|
674
|
-
isDecorativeRefresh ? 16 : isDrillIn ? 24 : isTertiary || isAccountIcon && !isAccountCreate ? 38 : 36
|
|
675
|
-
if isTertiary {
|
|
676
|
-
button.pressedBackgroundColor = nativeListColor(
|
|
677
|
-
currentTheme, "rowPressedBackground", "#E8E8E8")
|
|
678
|
-
button.layer.borderWidth = 1
|
|
679
|
-
button.layer.borderColor = UIColor.clear.cgColor
|
|
680
|
-
button.layer.cornerRadius = 19
|
|
681
|
-
button.contentEdgeInsets = UIEdgeInsets(top: 6, left: 6, bottom: 6, right: 6)
|
|
682
|
-
}
|
|
512
|
+
let size: CGFloat = isDrillIn ? 24 : isAccountIcon && !isAccountCreate ? 38 : 36
|
|
683
513
|
if isAccountCreate { button.layer.cornerRadius = 8 }
|
|
684
514
|
if isAccountIcon && !isAccountCreate && !data.string("actionKey").isEmpty {
|
|
685
515
|
button.pressedBackgroundColor = nativeListColor(
|
|
@@ -817,19 +647,6 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
817
647
|
}
|
|
818
648
|
button.titleLabel?.font = font
|
|
819
649
|
attributed.addAttributes(attributes, range: NSRange(location: 0, length: attributed.length))
|
|
820
|
-
if style["fontSize"] != nil,
|
|
821
|
-
let ranges = valuePairSubscriptRanges[ObjectIdentifier(button)]
|
|
822
|
-
{
|
|
823
|
-
for (range, isPrimary) in ranges {
|
|
824
|
-
let weight = style["fontWeight"] == nil
|
|
825
|
-
? (isPrimary ? NativeListFontWeight.medium : NativeListFontWeight.regular)
|
|
826
|
-
: marketFontWeight(style.string("fontWeight"), fallback: .regular)
|
|
827
|
-
attributed.addAttribute(
|
|
828
|
-
.font,
|
|
829
|
-
value: nativeListFont(ofSize: ceil(size * 0.6), weight: weight, fonts: fonts),
|
|
830
|
-
range: range)
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
650
|
button.setAttributedTitle(attributed, for: .normal)
|
|
834
651
|
}
|
|
835
652
|
|
|
@@ -70,10 +70,8 @@ final class NativeListActivityDetailsView: UIStackView {
|
|
|
70
70
|
let verticalPadding = CGFloat(style.double("verticalPadding", default: 8))
|
|
71
71
|
let lineGap = CGFloat(style.double("lineGap"))
|
|
72
72
|
let gap = CGFloat(style.double("leadingGap", default: 12))
|
|
73
|
-
let hideLeading = data.bool("hideLeading")
|
|
74
73
|
let imageWidth = CGFloat(image.double("width", default: 40))
|
|
75
74
|
let imageHeight = CGFloat(image.double("height", default: 40))
|
|
76
|
-
let leadingWidth = hideLeading ? 0 : imageWidth + gap
|
|
77
75
|
let mainWidth = max(0, width - horizontalPadding * 2)
|
|
78
76
|
|
|
79
77
|
let amounts = data.dictionaries("amounts").map { amount -> (width: CGFloat, height: CGFloat) in
|
|
@@ -114,10 +112,10 @@ final class NativeListActivityDetailsView: UIStackView {
|
|
|
114
112
|
let feeColumn = data.dictionary("fee") == nil ? 0 : gap + feeWidth
|
|
115
113
|
let identityWidth: CGFloat
|
|
116
114
|
if table {
|
|
117
|
-
let shared = (mainWidth -
|
|
115
|
+
let shared = (mainWidth - imageWidth - gap * 2 - feeColumn) / 2
|
|
118
116
|
identityWidth = min(mainWidth * 0.42, shared)
|
|
119
117
|
} else {
|
|
120
|
-
identityWidth = mainWidth -
|
|
118
|
+
identityWidth = mainWidth - imageWidth - gap * 2 - feeColumn - min(amountsWidth, mainWidth * 0.5)
|
|
121
119
|
}
|
|
122
120
|
|
|
123
121
|
let title = NativeListResolvedText(data.string("title"), style: style.dictionary("title"), size: 16,
|
|
@@ -142,7 +140,7 @@ final class NativeListActivityDetailsView: UIStackView {
|
|
|
142
140
|
return max(height, ceil(sizingButton.intrinsicContentSize.height))
|
|
143
141
|
} + 8
|
|
144
142
|
}
|
|
145
|
-
return max(
|
|
143
|
+
return max(imageHeight, identityHeight, amountsHeight, feeHeight) + actionsHeight + verticalPadding * 2
|
|
146
144
|
}
|
|
147
145
|
|
|
148
146
|
func bind(_ item: NativeListItem, theme: [String: Any]?, fonts: NativeListFontFamilies) {
|
|
@@ -152,28 +150,20 @@ final class NativeListActivityDetailsView: UIStackView {
|
|
|
152
150
|
let image = style.dictionary("image") ?? [:]
|
|
153
151
|
let table = data.string("presentation") == "table"
|
|
154
152
|
let gap = CGFloat(style.double("leadingGap", default: 12))
|
|
155
|
-
let hideLeading = data.bool("hideLeading")
|
|
156
153
|
main.spacing = gap
|
|
157
154
|
identity.spacing = CGFloat(style.double("lineGap"))
|
|
158
155
|
amounts.spacing = CGFloat(style.double("trailingGap", default: 2))
|
|
159
156
|
titleLine.spacing = CGFloat(style.double("titleBadgeGap", default: 4))
|
|
160
157
|
NSLayoutConstraint.deactivate(dimensions)
|
|
161
|
-
let visualWidth = visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40)))
|
|
162
|
-
if hideLeading { visualWidth.priority = UILayoutPriority(999) }
|
|
163
158
|
dimensions = [
|
|
164
|
-
|
|
159
|
+
visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40))),
|
|
165
160
|
visual.heightAnchor.constraint(equalToConstant: CGFloat(image.double("height", default: 40))),
|
|
166
161
|
amounts.widthAnchor.constraint(lessThanOrEqualTo: main.widthAnchor, multiplier: table ? 0.42 : 0.5),
|
|
167
162
|
]
|
|
168
163
|
if table { dimensions.append(amounts.widthAnchor.constraint(equalTo: identity.widthAnchor)) }
|
|
169
164
|
NSLayoutConstraint.activate(dimensions)
|
|
170
|
-
visual.
|
|
171
|
-
|
|
172
|
-
visual.recycle()
|
|
173
|
-
} else {
|
|
174
|
-
visual.bind(data.dictionary("leading") ?? [:], style: image, key: item.key, theme: theme,
|
|
175
|
-
isUnread: false, secondaryVisual: data.dictionary("secondaryLeading"), fonts: fonts)
|
|
176
|
-
}
|
|
165
|
+
visual.bind(data.dictionary("leading") ?? [:], style: image, key: item.key, theme: theme,
|
|
166
|
+
isUnread: false, secondaryVisual: data.dictionary("secondaryLeading"), fonts: fonts)
|
|
177
167
|
NativeListResolvedText(data.string("title"), style: style.dictionary("title"), size: 16,
|
|
178
168
|
weight: .medium, color: nativeListColor(theme, "primaryText", "#202020"), lineHeight: 24,
|
|
179
169
|
lines: 1, fonts: fonts
|
|
@@ -235,7 +225,7 @@ final class NativeListActivityDetailsView: UIStackView {
|
|
|
235
225
|
let actionData = data.dictionaries("footerActions")
|
|
236
226
|
actionKeys = actionData.map { $0.string("key") }
|
|
237
227
|
actions.isHidden = actionData.isEmpty
|
|
238
|
-
actions.directionalLayoutMargins = NSDirectionalEdgeInsets(top: 0, leading:
|
|
228
|
+
actions.directionalLayoutMargins = NSDirectionalEdgeInsets(top: 0, leading: CGFloat(image.double("width", default: 40)) + gap, bottom: 0, trailing: 0)
|
|
239
229
|
for (index, descriptor) in actionData.enumerated() {
|
|
240
230
|
let button = UIButton(type: .system); button.tag = index
|
|
241
231
|
button.setTitle(descriptor.string("label"), for: .normal)
|
|
@@ -259,7 +249,7 @@ final class NativeListActivityDetailsView: UIStackView {
|
|
|
259
249
|
onAction?(actionKeys[button.tag], button, "footerAction", button.tag)
|
|
260
250
|
}
|
|
261
251
|
func recycle() {
|
|
262
|
-
visual.recycle();
|
|
252
|
+
visual.recycle(); amountViews.forEach { $0.recycle() }; actionKeys = []; descriptionKey = ""
|
|
263
253
|
}
|
|
264
254
|
}
|
|
265
255
|
|
|
@@ -97,7 +97,6 @@ final class NativeListActivityCell: NativeListRendererCell {
|
|
|
97
97
|
details.recycle()
|
|
98
98
|
let style = data.dictionary("style") ?? [:]
|
|
99
99
|
let image = style.dictionary("image") ?? [:]
|
|
100
|
-
let hideLeading = data.bool("hideLeading")
|
|
101
100
|
root.spacing = 12
|
|
102
101
|
root.setCustomSpacing(CGFloat(style.double("leadingGap", default: 12)), after: visual)
|
|
103
102
|
switch style.dictionary("container")?.string("contentVerticalAlignment") {
|
|
@@ -114,17 +113,12 @@ final class NativeListActivityCell: NativeListRendererCell {
|
|
|
114
113
|
bottom: CGFloat(style.double("verticalPadding", default: 8)),
|
|
115
114
|
right: CGFloat(style.double("horizontalPadding", default: layout == "table" ? 16 : 12)))
|
|
116
115
|
NSLayoutConstraint.deactivate(dimensions)
|
|
117
|
-
let visualWidth = visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40)))
|
|
118
|
-
if hideLeading { visualWidth.priority = UILayoutPriority(999) }
|
|
119
116
|
dimensions = [
|
|
120
|
-
|
|
117
|
+
visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40))),
|
|
121
118
|
visual.heightAnchor.constraint(equalToConstant: CGFloat(image.double("height", default: 40))),
|
|
122
119
|
]
|
|
123
120
|
NSLayoutConstraint.activate(dimensions)
|
|
124
|
-
|
|
125
|
-
if hideLeading {
|
|
126
|
-
visual.recycle()
|
|
127
|
-
} else if let leading = data.dictionary("leading") {
|
|
121
|
+
if let leading = data.dictionary("leading") {
|
|
128
122
|
visual.bind(
|
|
129
123
|
leading, style: image, key: item.key, theme: theme, isUnread: false,
|
|
130
124
|
secondaryVisual: data.dictionary("secondaryLeading"), fonts: fonts)
|