@onekeyfe/react-native-native-list 6.7.0-alpha.343 → 6.7.0-alpha.354
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 +7 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +240 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +7 -4
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +6 -3
- 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 +87 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +135 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +43 -14
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +17 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +22 -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 +585 -21
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +1 -0
- package/docs/ROW_TEMPLATES.md +60 -9
- package/docs/SPEC.md +361 -8
- package/docs/STYLE_SPEC.md +6 -0
- package/ios/HybridNativeList.swift +10 -0
- package/ios/NativeListAccessoryStack.swift +220 -37
- package/ios/NativeListActivityDetailsView.swift +18 -8
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +105 -8
- package/ios/NativeListDesignAssets.swift +3 -0
- package/ios/NativeListIdentityRenderer.swift +119 -4
- package/ios/NativeListLeadingVisual.swift +49 -14
- package/ios/NativeListMessageRenderer.swift +34 -1
- package/ios/NativeListModels.swift +16 -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 +331 -29
- 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_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_refresh_ccw_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +56 -0
- package/ios/tests/NativeListLifecycleTests.swift +890 -3
- package/lib/module/NativeList.js +64 -27
- package/lib/module/NativeList.web.js +84 -17
- package/lib/module/models.js +1 -0
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +532 -18
- package/lib/module/web/NativeListWebEngine.js +391 -24
- package/lib/module/web/templates/ActivityRowRenderer.js +8 -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 +90 -4
- 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 +3 -0
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +9 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +5 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +6 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +7 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +6 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +11 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +2 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +3 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +1 -0
- package/lib/typescript/src/NativeList.d.ts +2 -2
- package/lib/typescript/src/NativeList.nitro.d.ts +1 -0
- package/lib/typescript/src/NativeList.types.d.ts +8 -0
- package/lib/typescript/src/models.d.ts +101 -9
- package/lib/typescript/src/validation.d.ts +13 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +26 -0
- 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/MessageRowRenderer.d.ts +9 -3
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +9 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +5 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +6 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +7 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +6 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +11 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +2 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +3 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +1 -0
- package/package.json +3 -3
- package/react-native-native-list.podspec +1 -0
- package/src/NativeList.nitro.ts +1 -0
- package/src/NativeList.tsx +155 -69
- package/src/NativeList.types.ts +9 -0
- package/src/NativeList.web.tsx +159 -49
- package/src/models.ts +113 -3
- package/src/selection.ts +1 -0
- package/src/validation.ts +1156 -18
- package/src/web/NativeListWebEngine.ts +594 -28
- package/src/web/templates/ActivityRowRenderer.ts +14 -6
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +93 -20
- package/src/web/templates/IdentityRowRenderer.ts +150 -5
- package/src/web/templates/MessageRowRenderer.ts +23 -7
- package/src/web/templates/RowContainerStyle.ts +2 -0
- package/src/web/templates/RowRendererRegistry.ts +11 -1
- package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
|
@@ -3,12 +3,72 @@ 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?
|
|
6
8
|
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
|
+
}
|
|
7
67
|
|
|
8
68
|
override var isHighlighted: Bool {
|
|
9
69
|
didSet {
|
|
10
70
|
guard let pressedBackgroundColor else { return }
|
|
11
|
-
backgroundColor = isHighlighted ? pressedBackgroundColor :
|
|
71
|
+
backgroundColor = isHighlighted ? pressedBackgroundColor : normalBackgroundColor
|
|
12
72
|
}
|
|
13
73
|
}
|
|
14
74
|
|
|
@@ -52,6 +112,11 @@ final class NativeListAccessoryButton: UIButton {
|
|
|
52
112
|
|
|
53
113
|
override var intrinsicContentSize: CGSize {
|
|
54
114
|
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
|
+
}
|
|
55
120
|
guard selectorSummaryLineHeight != nil || marketLineHeight != nil,
|
|
56
121
|
let title = attributedTitle(for: .normal)
|
|
57
122
|
else { return size }
|
|
@@ -71,6 +136,10 @@ final class NativeListAccessoryButton: UIButton {
|
|
|
71
136
|
defer {
|
|
72
137
|
if let titleLabel {
|
|
73
138
|
var frame = titleLabel.frame
|
|
139
|
+
if let fixedTextLineHeight {
|
|
140
|
+
frame.size.height = fixedTextLineHeight
|
|
141
|
+
frame.origin.y = (bounds.height - fixedTextLineHeight) / 2
|
|
142
|
+
}
|
|
74
143
|
if contentVerticalAlignment == .top {
|
|
75
144
|
frame.origin.y = contentEdgeInsets.top
|
|
76
145
|
} else if contentVerticalAlignment == .bottom {
|
|
@@ -79,6 +148,7 @@ final class NativeListAccessoryButton: UIButton {
|
|
|
79
148
|
frame.origin.y += rowTextOffsetY
|
|
80
149
|
titleLabel.frame = frame
|
|
81
150
|
}
|
|
151
|
+
layoutHelp()
|
|
82
152
|
}
|
|
83
153
|
if let lineHeight = marketLineHeight, let titleLabel, let title = attributedTitle(for: .normal)
|
|
84
154
|
{
|
|
@@ -127,6 +197,8 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
127
197
|
private var boundCheckboxData: [String: Any]?
|
|
128
198
|
private var boundCheckboxTarget: NativeSelectionTarget?
|
|
129
199
|
private var semanticValueButtons: [UIButton] = []
|
|
200
|
+
private var valuePairSubscriptRanges: [ObjectIdentifier: [(NSRange, Bool)]] = [:]
|
|
201
|
+
private var tertiaryIconButtons: Set<ObjectIdentifier> = []
|
|
130
202
|
private var accessorySizeConstraints: [NSLayoutConstraint] = []
|
|
131
203
|
private var currentItem: NativeListItem?
|
|
132
204
|
private var currentTheme: [String: Any]?
|
|
@@ -210,14 +282,19 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
210
282
|
}
|
|
211
283
|
}
|
|
212
284
|
func anchorInset(for view: UIView) -> CGFloat {
|
|
213
|
-
|
|
214
|
-
|
|
285
|
+
guard accessoryButtons.contains(where: { $0 === view }), view.bounds.width == 38 else {
|
|
286
|
+
return 0
|
|
287
|
+
}
|
|
288
|
+
if tertiaryIconButtons.contains(ObjectIdentifier(view)) { return 7 }
|
|
289
|
+
return currentItem?.data.string("presentation") == "accountSelector" ? 7 : 0
|
|
215
290
|
}
|
|
216
291
|
func reset() {
|
|
217
292
|
NSLayoutConstraint.deactivate(accessorySizeConstraints)
|
|
218
293
|
accessorySizeConstraints.removeAll()
|
|
219
294
|
accessoryActions.removeAll()
|
|
220
295
|
semanticValueButtons.removeAll()
|
|
296
|
+
valuePairSubscriptRanges.removeAll()
|
|
297
|
+
tertiaryIconButtons.removeAll()
|
|
221
298
|
checkboxAction = nil
|
|
222
299
|
boundCheckboxData = nil
|
|
223
300
|
boundCheckboxTarget = nil
|
|
@@ -225,6 +302,7 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
225
302
|
contentGap = nil
|
|
226
303
|
currentItem = nil
|
|
227
304
|
for (index, button) in accessoryButtons.enumerated() {
|
|
305
|
+
button.tag = index
|
|
228
306
|
button.setAttributedTitle(nil, for: .normal)
|
|
229
307
|
button.setTitle(nil, for: .normal)
|
|
230
308
|
button.setImage(nil, for: .normal)
|
|
@@ -236,14 +314,23 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
236
314
|
button.contentHorizontalAlignment = .center
|
|
237
315
|
button.contentVerticalAlignment = .center
|
|
238
316
|
button.rowTextOffsetY = 0
|
|
317
|
+
button.helpBindingGeneration += 1
|
|
318
|
+
button.helpPrimaryLineOnly = false
|
|
319
|
+
button.showsHelpUnderline = false
|
|
239
320
|
button.transform = .identity
|
|
240
321
|
button.marketLineHeight = nil
|
|
241
322
|
button.selectorSummaryLineHeight = nil
|
|
242
323
|
button.backgroundColor = .clear
|
|
243
324
|
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
|
|
244
330
|
button.layer.cornerRadius = 0
|
|
245
331
|
button.isHidden = true
|
|
246
332
|
button.isEnabled = true
|
|
333
|
+
button.isUserInteractionEnabled = true
|
|
247
334
|
button.alpha = 1
|
|
248
335
|
button.accessibilityIdentifier = nil
|
|
249
336
|
button.accessibilityLabel = nil
|
|
@@ -253,9 +340,13 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
253
340
|
spinner.alpha = 1
|
|
254
341
|
}
|
|
255
342
|
@objc private func pressed(_ button: UIButton) {
|
|
256
|
-
guard
|
|
257
|
-
|
|
258
|
-
|
|
343
|
+
guard let controlIndex = accessoryButtons.firstIndex(where: { $0 === button }),
|
|
344
|
+
accessoryActions.indices.contains(controlIndex) else { return }
|
|
345
|
+
let action = accessoryActions[controlIndex]
|
|
346
|
+
if !action.0.isEmpty {
|
|
347
|
+
let anchor = accessoryButtons[controlIndex]
|
|
348
|
+
onAction?(action.0, anchor.helpPrimaryLineOnly ? anchor.helpAnchor : button, button.tag, action.1)
|
|
349
|
+
}
|
|
259
350
|
}
|
|
260
351
|
@objc private func checkboxPressed() {
|
|
261
352
|
if let action = checkboxAction { onAction?(action.0, checkboxButton, nil, action.1) }
|
|
@@ -267,8 +358,42 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
267
358
|
_ checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
268
359
|
) {
|
|
269
360
|
var textIndex = 0
|
|
270
|
-
for accessory in accessories.prefix(2) {
|
|
361
|
+
for (slot, accessory) in accessories.prefix(2).enumerated() {
|
|
362
|
+
let controlIndex = textIndex
|
|
271
363
|
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
|
|
272
397
|
case "value":
|
|
273
398
|
showAccessory(textIndex, accessory.string("text"))
|
|
274
399
|
semanticValueButtons.append(accessoryButtons[textIndex])
|
|
@@ -325,6 +450,7 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
325
450
|
textIndex += 1
|
|
326
451
|
default: break
|
|
327
452
|
}
|
|
453
|
+
if textIndex > controlIndex { accessoryButtons[controlIndex].tag = slot }
|
|
328
454
|
}
|
|
329
455
|
}
|
|
330
456
|
|
|
@@ -405,8 +531,12 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
405
531
|
theme: [String: Any]?
|
|
406
532
|
) {
|
|
407
533
|
guard accessoryButtons.indices.contains(index) else { return }
|
|
408
|
-
let
|
|
409
|
-
let
|
|
534
|
+
let primarySegments = accessory.dictionaries("primaryTextSegments")
|
|
535
|
+
let secondarySegments = accessory.dictionaries("secondaryTextSegments")
|
|
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()
|
|
410
540
|
guard !primary.isEmpty || !secondary.isEmpty else { return }
|
|
411
541
|
let button = accessoryButtons[index]
|
|
412
542
|
let text = NSMutableAttributedString()
|
|
@@ -414,45 +544,66 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
414
544
|
primaryParagraph.alignment = .right
|
|
415
545
|
primaryParagraph.minimumLineHeight = 20
|
|
416
546
|
primaryParagraph.maximumLineHeight = 20
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
accessory.string("primaryTone"),
|
|
424
|
-
defaultTone: "primary",
|
|
425
|
-
theme: theme
|
|
426
|
-
),
|
|
427
|
-
.paragraphStyle: primaryParagraph,
|
|
428
|
-
]
|
|
429
|
-
))
|
|
547
|
+
var subscriptRanges: [(NSRange, Bool)] = []
|
|
548
|
+
appendValuePairLine(
|
|
549
|
+
to: text, fallback: primary, segments: primarySegments, fontSize: 16,
|
|
550
|
+
weight: .medium,
|
|
551
|
+
color: accessoryTextColor(accessory.string("primaryTone"), defaultTone: "primary", theme: theme),
|
|
552
|
+
paragraph: primaryParagraph, isPrimary: true, subscriptRanges: &subscriptRanges)
|
|
430
553
|
if !primary.isEmpty, !secondary.isEmpty { text.append(NSAttributedString(string: "\n")) }
|
|
431
554
|
let secondaryParagraph = NSMutableParagraphStyle()
|
|
432
555
|
secondaryParagraph.alignment = .right
|
|
433
556
|
secondaryParagraph.minimumLineHeight = 20
|
|
434
557
|
secondaryParagraph.maximumLineHeight = 20
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
.foregroundColor: accessoryTextColor(
|
|
441
|
-
accessory.string("secondaryTone"),
|
|
442
|
-
defaultTone: "secondary",
|
|
443
|
-
theme: theme
|
|
444
|
-
),
|
|
445
|
-
.paragraphStyle: secondaryParagraph,
|
|
446
|
-
]
|
|
447
|
-
))
|
|
558
|
+
appendValuePairLine(
|
|
559
|
+
to: text, fallback: secondary, segments: secondarySegments, fontSize: 14,
|
|
560
|
+
weight: .regular,
|
|
561
|
+
color: accessoryTextColor(accessory.string("secondaryTone"), defaultTone: "secondary", theme: theme),
|
|
562
|
+
paragraph: secondaryParagraph, isPrimary: false, subscriptRanges: &subscriptRanges)
|
|
448
563
|
button.isHidden = false
|
|
449
564
|
button.titleLabel?.numberOfLines = 2
|
|
450
565
|
button.contentHorizontalAlignment = .trailing
|
|
451
566
|
button.setAttributedTitle(text, for: .normal)
|
|
567
|
+
valuePairSubscriptRanges[ObjectIdentifier(button)] = subscriptRanges
|
|
452
568
|
button.setContentHuggingPriority(.required, for: .horizontal)
|
|
453
569
|
button.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
454
570
|
while accessoryActions.count <= index { accessoryActions.append(("", nil)) }
|
|
455
571
|
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
|
+
}
|
|
456
607
|
}
|
|
457
608
|
|
|
458
609
|
private func showMenuAccessory(
|
|
@@ -500,7 +651,12 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
500
651
|
? nativeListColor(currentTheme, "iconSubdued", "#8D8D8D")
|
|
501
652
|
: UIColor(nativeListHex: data.string("tintColor", default: "#646464"), fallback: .darkGray)
|
|
502
653
|
button.tintColor = tintColor
|
|
503
|
-
|
|
654
|
+
let isDecorativeRefresh =
|
|
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 {
|
|
504
660
|
button.setImage(image, for: .normal)
|
|
505
661
|
button.setImage(
|
|
506
662
|
image.withTintColor(tintColor, renderingMode: .alwaysOriginal),
|
|
@@ -508,8 +664,22 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
508
664
|
)
|
|
509
665
|
}
|
|
510
666
|
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
|
+
}
|
|
511
671
|
let isAccountIcon = currentItem?.data.string("presentation") == "accountSelector" && !isDrillIn
|
|
512
|
-
|
|
672
|
+
button.isUserInteractionEnabled = !isDecorativeRefresh
|
|
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
|
+
}
|
|
513
683
|
if isAccountCreate { button.layer.cornerRadius = 8 }
|
|
514
684
|
if isAccountIcon && !isAccountCreate && !data.string("actionKey").isEmpty {
|
|
515
685
|
button.pressedBackgroundColor = nativeListColor(
|
|
@@ -647,6 +817,19 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
647
817
|
}
|
|
648
818
|
button.titleLabel?.font = font
|
|
649
819
|
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
|
+
}
|
|
650
833
|
button.setAttributedTitle(attributed, for: .normal)
|
|
651
834
|
}
|
|
652
835
|
|
|
@@ -70,8 +70,10 @@ 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")
|
|
73
74
|
let imageWidth = CGFloat(image.double("width", default: 40))
|
|
74
75
|
let imageHeight = CGFloat(image.double("height", default: 40))
|
|
76
|
+
let leadingWidth = hideLeading ? 0 : imageWidth + gap
|
|
75
77
|
let mainWidth = max(0, width - horizontalPadding * 2)
|
|
76
78
|
|
|
77
79
|
let amounts = data.dictionaries("amounts").map { amount -> (width: CGFloat, height: CGFloat) in
|
|
@@ -112,10 +114,10 @@ final class NativeListActivityDetailsView: UIStackView {
|
|
|
112
114
|
let feeColumn = data.dictionary("fee") == nil ? 0 : gap + feeWidth
|
|
113
115
|
let identityWidth: CGFloat
|
|
114
116
|
if table {
|
|
115
|
-
let shared = (mainWidth -
|
|
117
|
+
let shared = (mainWidth - leadingWidth - gap - feeColumn) / 2
|
|
116
118
|
identityWidth = min(mainWidth * 0.42, shared)
|
|
117
119
|
} else {
|
|
118
|
-
identityWidth = mainWidth -
|
|
120
|
+
identityWidth = mainWidth - leadingWidth - gap - feeColumn - min(amountsWidth, mainWidth * 0.5)
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
let title = NativeListResolvedText(data.string("title"), style: style.dictionary("title"), size: 16,
|
|
@@ -140,7 +142,7 @@ final class NativeListActivityDetailsView: UIStackView {
|
|
|
140
142
|
return max(height, ceil(sizingButton.intrinsicContentSize.height))
|
|
141
143
|
} + 8
|
|
142
144
|
}
|
|
143
|
-
return max(imageHeight, identityHeight, amountsHeight, feeHeight) + actionsHeight + verticalPadding * 2
|
|
145
|
+
return max(hideLeading ? 0 : imageHeight, identityHeight, amountsHeight, feeHeight) + actionsHeight + verticalPadding * 2
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
func bind(_ item: NativeListItem, theme: [String: Any]?, fonts: NativeListFontFamilies) {
|
|
@@ -150,20 +152,28 @@ final class NativeListActivityDetailsView: UIStackView {
|
|
|
150
152
|
let image = style.dictionary("image") ?? [:]
|
|
151
153
|
let table = data.string("presentation") == "table"
|
|
152
154
|
let gap = CGFloat(style.double("leadingGap", default: 12))
|
|
155
|
+
let hideLeading = data.bool("hideLeading")
|
|
153
156
|
main.spacing = gap
|
|
154
157
|
identity.spacing = CGFloat(style.double("lineGap"))
|
|
155
158
|
amounts.spacing = CGFloat(style.double("trailingGap", default: 2))
|
|
156
159
|
titleLine.spacing = CGFloat(style.double("titleBadgeGap", default: 4))
|
|
157
160
|
NSLayoutConstraint.deactivate(dimensions)
|
|
161
|
+
let visualWidth = visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40)))
|
|
162
|
+
if hideLeading { visualWidth.priority = UILayoutPriority(999) }
|
|
158
163
|
dimensions = [
|
|
159
|
-
|
|
164
|
+
visualWidth,
|
|
160
165
|
visual.heightAnchor.constraint(equalToConstant: CGFloat(image.double("height", default: 40))),
|
|
161
166
|
amounts.widthAnchor.constraint(lessThanOrEqualTo: main.widthAnchor, multiplier: table ? 0.42 : 0.5),
|
|
162
167
|
]
|
|
163
168
|
if table { dimensions.append(amounts.widthAnchor.constraint(equalTo: identity.widthAnchor)) }
|
|
164
169
|
NSLayoutConstraint.activate(dimensions)
|
|
165
|
-
visual.
|
|
166
|
-
|
|
170
|
+
visual.isHidden = hideLeading
|
|
171
|
+
if hideLeading {
|
|
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
|
+
}
|
|
167
177
|
NativeListResolvedText(data.string("title"), style: style.dictionary("title"), size: 16,
|
|
168
178
|
weight: .medium, color: nativeListColor(theme, "primaryText", "#202020"), lineHeight: 24,
|
|
169
179
|
lines: 1, fonts: fonts
|
|
@@ -225,7 +235,7 @@ final class NativeListActivityDetailsView: UIStackView {
|
|
|
225
235
|
let actionData = data.dictionaries("footerActions")
|
|
226
236
|
actionKeys = actionData.map { $0.string("key") }
|
|
227
237
|
actions.isHidden = actionData.isEmpty
|
|
228
|
-
actions.directionalLayoutMargins = NSDirectionalEdgeInsets(top: 0, leading: CGFloat(image.double("width", default: 40)) + gap, bottom: 0, trailing: 0)
|
|
238
|
+
actions.directionalLayoutMargins = NSDirectionalEdgeInsets(top: 0, leading: hideLeading ? 0 : CGFloat(image.double("width", default: 40)) + gap, bottom: 0, trailing: 0)
|
|
229
239
|
for (index, descriptor) in actionData.enumerated() {
|
|
230
240
|
let button = UIButton(type: .system); button.tag = index
|
|
231
241
|
button.setTitle(descriptor.string("label"), for: .normal)
|
|
@@ -249,7 +259,7 @@ final class NativeListActivityDetailsView: UIStackView {
|
|
|
249
259
|
onAction?(actionKeys[button.tag], button, "footerAction", button.tag)
|
|
250
260
|
}
|
|
251
261
|
func recycle() {
|
|
252
|
-
visual.recycle(); amountViews.forEach { $0.recycle() }; actionKeys = []; descriptionKey = ""
|
|
262
|
+
visual.recycle(); visual.isHidden = false; amountViews.forEach { $0.recycle() }; actionKeys = []; descriptionKey = ""
|
|
253
263
|
}
|
|
254
264
|
}
|
|
255
265
|
|
|
@@ -97,6 +97,7 @@ 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")
|
|
100
101
|
root.spacing = 12
|
|
101
102
|
root.setCustomSpacing(CGFloat(style.double("leadingGap", default: 12)), after: visual)
|
|
102
103
|
switch style.dictionary("container")?.string("contentVerticalAlignment") {
|
|
@@ -113,12 +114,17 @@ final class NativeListActivityCell: NativeListRendererCell {
|
|
|
113
114
|
bottom: CGFloat(style.double("verticalPadding", default: 8)),
|
|
114
115
|
right: CGFloat(style.double("horizontalPadding", default: layout == "table" ? 16 : 12)))
|
|
115
116
|
NSLayoutConstraint.deactivate(dimensions)
|
|
117
|
+
let visualWidth = visual.widthAnchor.constraint(equalToConstant: CGFloat(image.double("width", default: 40)))
|
|
118
|
+
if hideLeading { visualWidth.priority = UILayoutPriority(999) }
|
|
116
119
|
dimensions = [
|
|
117
|
-
|
|
120
|
+
visualWidth,
|
|
118
121
|
visual.heightAnchor.constraint(equalToConstant: CGFloat(image.double("height", default: 40))),
|
|
119
122
|
]
|
|
120
123
|
NSLayoutConstraint.activate(dimensions)
|
|
121
|
-
|
|
124
|
+
visual.isHidden = hideLeading
|
|
125
|
+
if hideLeading {
|
|
126
|
+
visual.recycle()
|
|
127
|
+
} else if let leading = data.dictionary("leading") {
|
|
122
128
|
visual.bind(
|
|
123
129
|
leading, style: image, key: item.key, theme: theme, isUnread: false,
|
|
124
130
|
secondaryVisual: data.dictionary("secondaryLeading"), fonts: fonts)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
final class NativeListButtonGroupCell: NativeListRendererCell {
|
|
4
|
+
override class func measure(
|
|
5
|
+
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String,
|
|
6
|
+
fonts: NativeListFontFamilies
|
|
7
|
+
) -> CGFloat? { 64 }
|
|
8
|
+
|
|
9
|
+
private var buttons: [UIButton] = []
|
|
10
|
+
private var actionKeys: [String] = []
|
|
11
|
+
private var rowOpacity: CGFloat = 1
|
|
12
|
+
|
|
13
|
+
override func applyAppearance() {
|
|
14
|
+
super.applyAppearance()
|
|
15
|
+
contentView.alpha = rowOpacity
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override init(frame: CGRect) {
|
|
19
|
+
super.init(frame: frame)
|
|
20
|
+
root.axis = .horizontal
|
|
21
|
+
root.alignment = .fill
|
|
22
|
+
root.distribution = .fillEqually
|
|
23
|
+
root.spacing = 10
|
|
24
|
+
}
|
|
25
|
+
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
26
|
+
|
|
27
|
+
override func bindContent(
|
|
28
|
+
_ item: NativeListItem, theme: [String: Any]?, layout: String,
|
|
29
|
+
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
30
|
+
) {
|
|
31
|
+
recycleContent()
|
|
32
|
+
rowOpacity = CGFloat(item.data.dictionary("style")?.dictionary("container")?.double("opacity", default: item.data.double("opacity", default: 1)) ?? item.data.double("opacity", default: 1))
|
|
33
|
+
contentInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0)
|
|
34
|
+
let info = nativeListColor(theme, "info", "#0F69F6")
|
|
35
|
+
for (index, descriptor) in item.data.dictionaries("buttons").enumerated() {
|
|
36
|
+
let button = NativeListAccessoryButton(type: .custom)
|
|
37
|
+
button.tag = index
|
|
38
|
+
button.setTitle(descriptor.string("label"), for: .normal)
|
|
39
|
+
button.titleLabel?.font = nativeListFont(ofSize: 14, weight: .medium, fonts: fonts)
|
|
40
|
+
button.titleLabel?.lineBreakMode = .byTruncatingTail
|
|
41
|
+
button.setTitleColor(info, for: .normal)
|
|
42
|
+
button.contentEdgeInsets = UIEdgeInsets(top: 12, left: 8, bottom: 12, right: 8)
|
|
43
|
+
button.layer.cornerRadius = 12
|
|
44
|
+
button.layer.borderWidth = 1
|
|
45
|
+
button.layer.borderColor = info.withAlphaComponent(0.35).cgColor
|
|
46
|
+
button.normalBackgroundColor = .clear
|
|
47
|
+
button.pressedBackgroundColor = info.withAlphaComponent(0.17)
|
|
48
|
+
button.isEnabled = !item.data.bool("disabled") && !descriptor.bool("disabled") && !descriptor.bool("loading")
|
|
49
|
+
button.alpha = button.isEnabled ? 1 : 0.4
|
|
50
|
+
button.accessibilityIdentifier = descriptor["testID"] as? String
|
|
51
|
+
button.accessibilityLabel = descriptor.string("accessibilityLabel", default: descriptor.string("label"))
|
|
52
|
+
button.addTarget(self, action: #selector(pressed(_:)), for: .touchUpInside)
|
|
53
|
+
if descriptor.bool("loading"), let titleLabel = button.titleLabel {
|
|
54
|
+
let spinner = UIActivityIndicatorView(style: .medium)
|
|
55
|
+
spinner.color = info
|
|
56
|
+
spinner.isUserInteractionEnabled = false
|
|
57
|
+
spinner.translatesAutoresizingMaskIntoConstraints = false
|
|
58
|
+
button.addSubview(spinner)
|
|
59
|
+
button.contentEdgeInsets = UIEdgeInsets(top: 12, left: 36, bottom: 12, right: 8)
|
|
60
|
+
NSLayoutConstraint.activate([
|
|
61
|
+
spinner.trailingAnchor.constraint(equalTo: titleLabel.leadingAnchor, constant: -8),
|
|
62
|
+
spinner.centerYAnchor.constraint(equalTo: button.centerYAnchor),
|
|
63
|
+
spinner.widthAnchor.constraint(equalToConstant: 20),
|
|
64
|
+
spinner.heightAnchor.constraint(equalToConstant: 20),
|
|
65
|
+
])
|
|
66
|
+
spinner.startAnimating()
|
|
67
|
+
}
|
|
68
|
+
buttons.append(button)
|
|
69
|
+
actionKeys.append(descriptor.string("actionKey"))
|
|
70
|
+
root.addArrangedSubview(button)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@objc private func pressed(_ button: UIButton) {
|
|
75
|
+
guard button.isEnabled, buttons.indices.contains(button.tag), buttons[button.tag] === button else { return }
|
|
76
|
+
emitAction(actionKeys[button.tag], from: button, source: "buttonGroup", slot: button.tag)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
override func recycleContent() {
|
|
80
|
+
for button in buttons {
|
|
81
|
+
button.removeTarget(self, action: nil, for: .allEvents)
|
|
82
|
+
button.subviews.compactMap { $0 as? UIActivityIndicatorView }.forEach { $0.stopAnimating() }
|
|
83
|
+
root.removeArrangedSubview(button)
|
|
84
|
+
button.removeFromSuperview()
|
|
85
|
+
}
|
|
86
|
+
buttons.removeAll()
|
|
87
|
+
actionKeys.removeAll()
|
|
88
|
+
}
|
|
89
|
+
}
|