@onekeyfe/react-native-native-list 6.7.0-alpha.359 → 6.7.0-alpha.363
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 +29 -587
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +0 -1
- package/docs/ROW_TEMPLATES.md +9 -60
- package/docs/SPEC.md +15 -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 +16 -128
- package/ios/NativeListDesignAssets.swift +0 -3
- package/ios/NativeListIdentityRenderer.swift +5 -123
- 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 -335
- package/ios/tests/NativeListActivityPresentationTests.swift +0 -56
- package/ios/tests/NativeListLifecycleTests.swift +3 -1283
- 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
|
@@ -29,9 +29,7 @@ enum NativeListMessageRenderer {
|
|
|
29
29
|
body = NativeListResolvedText(
|
|
30
30
|
item.data.string("body"), style: style.dictionary("body"), size: 14,
|
|
31
31
|
color: nativeListColor(theme, "secondaryText", "#646464"), lineHeight: 20,
|
|
32
|
-
lines: item.data.int("bodyLines", default: 3),
|
|
33
|
-
breakMode: item.data.int("bodyLines", default: 3) == 0 ? .byWordWrapping : .byTruncatingTail,
|
|
34
|
-
fonts: fonts)
|
|
32
|
+
lines: item.data.int("bodyLines", default: 3), fonts: fonts)
|
|
35
33
|
time = NativeListResolvedText(
|
|
36
34
|
item.data.string("time"), style: style.dictionary("time"), size: 12,
|
|
37
35
|
color: nativeListColor(theme, "disabledText", "#8D8D8D"), lineHeight: 16, lines: 1,
|
|
@@ -152,11 +150,6 @@ enum NativeListMessageRenderer {
|
|
|
152
150
|
}
|
|
153
151
|
|
|
154
152
|
final class NativeListMessageCell: NativeListRendererCell {
|
|
155
|
-
private let topWarningBorder = CALayer()
|
|
156
|
-
private let bottomWarningBorder = CALayer()
|
|
157
|
-
private var warningBorderWidth: CGFloat = 0
|
|
158
|
-
private var warningBorderColor = UIColor.clear
|
|
159
|
-
private var isInlineWarning = false
|
|
160
153
|
override class func measure(
|
|
161
154
|
_ item: NativeListItem, width: CGFloat, theme: [String: Any]?, layout: String,
|
|
162
155
|
fonts: NativeListFontFamilies
|
|
@@ -174,10 +167,6 @@ final class NativeListMessageCell: NativeListRendererCell {
|
|
|
174
167
|
_ item: NativeListItem, theme: [String: Any]?, layout: String,
|
|
175
168
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
176
169
|
) {
|
|
177
|
-
let container = item.data.dictionary("style")?.dictionary("container") ?? [:]
|
|
178
|
-
isInlineWarning = item.data.string("presentation") == "inlineWarning"
|
|
179
|
-
warningBorderWidth = isInlineWarning ? CGFloat(container.double("borderWidth")) : 0
|
|
180
|
-
warningBorderColor = UIColor(nativeListHex: container.string("borderColor"), fallback: .clear)
|
|
181
170
|
let resolved = NativeListMessageRenderer.Resolved(
|
|
182
171
|
item, theme: theme, layout: layout, fonts: fonts)
|
|
183
172
|
views.bind(resolved, item: item, theme: theme, fonts: fonts)
|
|
@@ -185,27 +174,5 @@ final class NativeListMessageCell: NativeListRendererCell {
|
|
|
185
174
|
top: resolved.verticalPadding, left: resolved.horizontalPadding,
|
|
186
175
|
bottom: resolved.verticalPadding, right: resolved.horizontalPadding)
|
|
187
176
|
}
|
|
188
|
-
override func applyAppearance() {
|
|
189
|
-
super.applyAppearance()
|
|
190
|
-
if isInlineWarning {
|
|
191
|
-
layer.cornerRadius = 0
|
|
192
|
-
contentView.layer.cornerRadius = 0
|
|
193
|
-
contentView.layer.borderWidth = 0
|
|
194
|
-
topWarningBorder.backgroundColor = warningBorderColor.cgColor
|
|
195
|
-
bottomWarningBorder.backgroundColor = warningBorderColor.cgColor
|
|
196
|
-
if topWarningBorder.superlayer == nil { contentView.layer.addSublayer(topWarningBorder) }
|
|
197
|
-
if bottomWarningBorder.superlayer == nil { contentView.layer.addSublayer(bottomWarningBorder) }
|
|
198
|
-
} else {
|
|
199
|
-
topWarningBorder.removeFromSuperlayer()
|
|
200
|
-
bottomWarningBorder.removeFromSuperlayer()
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
override func layoutSubviews() {
|
|
204
|
-
super.layoutSubviews()
|
|
205
|
-
let height = max(0, warningBorderWidth)
|
|
206
|
-
topWarningBorder.frame = CGRect(x: 0, y: 0, width: contentView.bounds.width, height: height)
|
|
207
|
-
bottomWarningBorder.frame = CGRect(
|
|
208
|
-
x: 0, y: contentView.bounds.height - height, width: contentView.bounds.width, height: height)
|
|
209
|
-
}
|
|
210
177
|
override func recycleContent() { views.recycle() }
|
|
211
178
|
}
|
|
@@ -3,7 +3,7 @@ import UIKit
|
|
|
3
3
|
|
|
4
4
|
// Template type alone partitions reuse; data keys and styles never select a renderer.
|
|
5
5
|
enum NativeListRendererKey: String, CaseIterable {
|
|
6
|
-
case message, rail, mediaTile, action,
|
|
6
|
+
case message, rail, mediaTile, action, system, activity, dataRow, metricCard, market, identity, sectionHeader, walletGroup
|
|
7
7
|
/// Not a template: legacy accepted any non-empty type and drew an empty row with the
|
|
8
8
|
/// shared chrome. Unknown types keep that placeholder instead of failing the snapshot.
|
|
9
9
|
case unsupported = "__nativeListUnsupported"
|
|
@@ -35,7 +35,7 @@ struct NativeListItem {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
var isRowPressEnabled: Bool {
|
|
38
|
-
|
|
38
|
+
!data.bool("disabled") &&
|
|
39
39
|
!data.bool("pressDisabled") &&
|
|
40
40
|
(type != "system" || data.string("variant") == "retry")
|
|
41
41
|
}
|
|
@@ -78,13 +78,7 @@ struct NativeListItem {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
struct NativeListConfig {
|
|
81
|
-
struct StructuralTransition {
|
|
82
|
-
let id: String
|
|
83
|
-
let duration: TimeInterval
|
|
84
|
-
let anchorKey: String?
|
|
85
|
-
}
|
|
86
81
|
let generation: Int
|
|
87
|
-
let structuralTransition: StructuralTransition?
|
|
88
82
|
let layout: String
|
|
89
83
|
let orientation: String
|
|
90
84
|
let gridColumns: Int
|
|
@@ -135,13 +129,6 @@ struct NativeListConfig {
|
|
|
135
129
|
let capabilities = root["capabilities"] as? [String: Any]
|
|
136
130
|
let sectionIndex = capabilities?["sectionIndex"] as? [String: Any]
|
|
137
131
|
let footer = try (root["fixedFooter"] as? [String: Any]).map(NativeListItem.init)
|
|
138
|
-
let transition = root["structuralTransition"] as? [String: Any]
|
|
139
|
-
let structuralTransition = (transition?["id"] as? String).map { id in
|
|
140
|
-
StructuralTransition(
|
|
141
|
-
id: id,
|
|
142
|
-
duration: min(2, max(0, (transition?["durationMs"] as? Double ?? 220) / 1000)),
|
|
143
|
-
anchorKey: transition?["anchorKey"] as? String)
|
|
144
|
-
}
|
|
145
132
|
|
|
146
133
|
let contentPadding = max(0, CGFloat(layoutData.double("contentPadding")))
|
|
147
134
|
let contentPaddingHorizontal = layoutData["contentPaddingHorizontal"] == nil
|
|
@@ -156,7 +143,6 @@ struct NativeListConfig {
|
|
|
156
143
|
|
|
157
144
|
return NativeListConfig(
|
|
158
145
|
generation: generation,
|
|
159
|
-
structuralTransition: structuralTransition,
|
|
160
146
|
layout: layout,
|
|
161
147
|
orientation: layoutData["orientation"] as? String ?? "vertical",
|
|
162
148
|
gridColumns: min(7, max(1, layoutData["gridColumns"] as? Int ?? 1)),
|
|
@@ -18,7 +18,6 @@ enum NativeListRendererRegistry {
|
|
|
18
18
|
.activity: (NativeListActivityCell.self, { NativeListActivityCell(frame: .zero) }),
|
|
19
19
|
.system: (NativeListSystemCell.self, { NativeListSystemCell(frame: .zero) }),
|
|
20
20
|
.action: (NativeListActionCell.self, { NativeListActionCell(frame: .zero) }),
|
|
21
|
-
.buttonGroup: (NativeListButtonGroupCell.self, { NativeListButtonGroupCell(frame: .zero) }),
|
|
22
21
|
.unsupported: (
|
|
23
22
|
NativeListUnsupportedCell.self, { NativeListUnsupportedCell(frame: .zero) }
|
|
24
23
|
),
|
|
@@ -26,8 +26,7 @@ struct NativeListResolvedText {
|
|
|
26
26
|
let style = style ?? [:]
|
|
27
27
|
self.tabular = tabular
|
|
28
28
|
self.preservesBreakMode = preservesBreakMode
|
|
29
|
-
|
|
30
|
-
self.lines = requestedLines == 0 ? 0 : min(3, max(1, requestedLines))
|
|
29
|
+
self.lines = min(3, max(1, style.int("lines", default: lines)))
|
|
31
30
|
explicitTruncation = style["lines"] != nil || style["truncate"] != nil
|
|
32
31
|
text =
|
|
33
32
|
self.lines == 1 && explicitTruncation
|
|
@@ -42,20 +42,6 @@ class NativeListRowHost: UICollectionViewCell {
|
|
|
42
42
|
var listStyle: [String: Any]?
|
|
43
43
|
var onAction: ((NativeListItem, String, NativeSelectionTarget?, NativeListActionOrigin?) -> Void)?
|
|
44
44
|
var onBindingInvalidated: ((NativeListRowHost, Int) -> Void)?
|
|
45
|
-
var structuralContentHeight: CGFloat?
|
|
46
|
-
|
|
47
|
-
override func layoutSubviews() {
|
|
48
|
-
super.layoutSubviews()
|
|
49
|
-
// UIKit relays out cells again when the collection's offset changes.
|
|
50
|
-
if let structuralContentHeight {
|
|
51
|
-
contentView.frame = CGRect(x: 0, y: 0, width: bounds.width, height: structuralContentHeight)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
override func prepareForReuse() {
|
|
56
|
-
super.prepareForReuse()
|
|
57
|
-
structuralContentHeight = nil
|
|
58
|
-
}
|
|
59
45
|
|
|
60
46
|
func bind(
|
|
61
47
|
item: NativeListItem, theme: [String: Any]?, layout: String, itemIndex: Int? = nil,
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import UIKit
|
|
2
2
|
|
|
3
3
|
final class NativeListDottedUnderlineLabel: NativeListTextLabel {
|
|
4
|
-
var usesDashedUnderline = false {
|
|
5
|
-
didSet {
|
|
6
|
-
dottedUnderlineLayer.lineDashPattern = usesDashedUnderline ? [3, 2] : [0, 4]
|
|
7
|
-
dottedUnderlineLayer.lineCap = usesDashedUnderline ? .butt : .round
|
|
8
|
-
setNeedsLayout()
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
4
|
var showsDottedUnderline = false {
|
|
12
5
|
didSet { setNeedsLayout() }
|
|
13
6
|
}
|
|
@@ -118,7 +111,6 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
118
111
|
private let mainStack = UIStackView()
|
|
119
112
|
private let titleRowStack = UIStackView()
|
|
120
113
|
private let titleLabel = NativeListDottedUnderlineLabel()
|
|
121
|
-
private let leadingBadge = NativeListInsetLabel()
|
|
122
114
|
private let titleSpinner = UIActivityIndicatorView(style: .medium)
|
|
123
115
|
private let subtitleLabel = NativeListTextLabel()
|
|
124
116
|
private let trailingStack = UIStackView()
|
|
@@ -156,7 +148,6 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
156
148
|
titleRowStack.axis = .horizontal
|
|
157
149
|
titleRowStack.alignment = .center
|
|
158
150
|
titleRowStack.spacing = 8
|
|
159
|
-
leadingBadge.heightAnchor.constraint(equalToConstant: 20).isActive = true
|
|
160
151
|
titleRowStack.addArrangedSubview(titleLabel)
|
|
161
152
|
mainStack.addArrangedSubview(titleRowStack)
|
|
162
153
|
mainStack.addArrangedSubview(subtitleLabel)
|
|
@@ -191,15 +182,6 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
191
182
|
selectorTypographyRestorers = []
|
|
192
183
|
currentItem = item
|
|
193
184
|
currentTheme = theme
|
|
194
|
-
if accessoryButtons[0].superview === titleRowStack {
|
|
195
|
-
titleRowStack.removeArrangedSubview(accessoryButtons[0])
|
|
196
|
-
accessoryButtons[0].removeFromSuperview()
|
|
197
|
-
trailingStack.insertArrangedSubview(accessoryButtons[0], at: 0)
|
|
198
|
-
}
|
|
199
|
-
titleRowStack.removeArrangedSubview(leadingBadge)
|
|
200
|
-
leadingBadge.removeFromSuperview()
|
|
201
|
-
leadingBadge.text = nil
|
|
202
|
-
leadingBadge.accessibilityLabel = nil
|
|
203
185
|
titleSpinner.stopAnimating()
|
|
204
186
|
NSLayoutConstraint.deactivate(selectorConstraints)
|
|
205
187
|
selectorConstraints = []
|
|
@@ -216,7 +198,6 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
216
198
|
titleLabel.removeGestureRecognizer(selectorTitleTap)
|
|
217
199
|
titleLabel.isUserInteractionEnabled = false
|
|
218
200
|
titleLabel.showsDottedUnderline = false
|
|
219
|
-
titleLabel.usesDashedUnderline = false
|
|
220
201
|
titleLabel.reservesDottedUnderlineSpace = false
|
|
221
202
|
titleLabel.dottedUnderlineVerticalOffset = 0
|
|
222
203
|
for label in [titleLabel, subtitleLabel] {
|
|
@@ -230,7 +211,6 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
230
211
|
label.rowVerticalAlignment = nil
|
|
231
212
|
}
|
|
232
213
|
titleLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
|
233
|
-
titleLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
234
214
|
subtitleLabel.font = nativeListFont(ofSize: 14, fonts: fonts)
|
|
235
215
|
subtitleLabel.textColor = nativeListColor(theme, "secondaryText", "#646464")
|
|
236
216
|
mainStack.alignment = .fill
|
|
@@ -248,10 +228,6 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
248
228
|
value.contentHorizontalAlignment = .center
|
|
249
229
|
value.contentVerticalAlignment = .center
|
|
250
230
|
value.rowTextOffsetY = 0
|
|
251
|
-
value.helpBindingGeneration += 1
|
|
252
|
-
value.helpPrimaryLineOnly = false
|
|
253
|
-
value.showsHelpUnderline = false
|
|
254
|
-
value.isUserInteractionEnabled = true
|
|
255
231
|
value.marketLineHeight = nil
|
|
256
232
|
value.selectorSummaryLineHeight = nil
|
|
257
233
|
value.isHidden = true
|
|
@@ -277,7 +253,6 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
277
253
|
if style["lineGap"] != nil { mainStack.spacing = CGFloat(style.double("lineGap")) }
|
|
278
254
|
if style["trailingGap"] != nil { trailingStack.spacing = CGFloat(style.double("trailingGap")) }
|
|
279
255
|
applyTextStyle(item)
|
|
280
|
-
bindPositionHeaderFields(item, theme: theme)
|
|
281
256
|
titleSpinner.color = titleLabel.textColor
|
|
282
257
|
updateTitleSpinner()
|
|
283
258
|
contentInsets = UIEdgeInsets(
|
|
@@ -298,63 +273,6 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
298
273
|
selectorConstraints.append(width)
|
|
299
274
|
}
|
|
300
275
|
}
|
|
301
|
-
private func bindPositionHeaderFields(_ item: NativeListItem, theme: [String: Any]?) {
|
|
302
|
-
let style = item.data.dictionary("style") ?? [:]
|
|
303
|
-
if let badge = item.data.dictionary("leadingBadge") {
|
|
304
|
-
leadingBadge.text = badge.string("text")
|
|
305
|
-
leadingBadge.font = nativeListFont(ofSize: 12, weight: .medium, fonts: fonts)
|
|
306
|
-
let tones = ["info": ("info", "#0F69F6"), "success": ("positive", "#008F5A"), "warning": ("caution", "#A35E00"), "danger": ("negative", "#CE2C31")]
|
|
307
|
-
if let tone = tones[badge.string("tone")] {
|
|
308
|
-
let color = nativeListColor(theme, tone.0, tone.1)
|
|
309
|
-
leadingBadge.textColor = color
|
|
310
|
-
leadingBadge.backgroundColor = color.withAlphaComponent(0.12)
|
|
311
|
-
if badge.string("tone") == "success", let background = theme?["successBackground"] as? String {
|
|
312
|
-
leadingBadge.backgroundColor = UIColor(nativeListHex: background, fallback: color.withAlphaComponent(0.12))
|
|
313
|
-
}
|
|
314
|
-
} else {
|
|
315
|
-
leadingBadge.textColor = nativeListColor(theme, "secondaryText", "#646464")
|
|
316
|
-
leadingBadge.backgroundColor = nativeListColor(theme, "strongBackground", "#F0F0F0")
|
|
317
|
-
}
|
|
318
|
-
let paragraph = NSMutableParagraphStyle()
|
|
319
|
-
paragraph.minimumLineHeight = 16
|
|
320
|
-
paragraph.maximumLineHeight = 16
|
|
321
|
-
leadingBadge.attributedText = NSAttributedString(
|
|
322
|
-
string: badge.string("text"), attributes: [
|
|
323
|
-
.font: leadingBadge.font as Any,
|
|
324
|
-
.foregroundColor: leadingBadge.textColor as Any,
|
|
325
|
-
.paragraphStyle: paragraph,
|
|
326
|
-
])
|
|
327
|
-
leadingBadge.horizontalInset = 8
|
|
328
|
-
leadingBadge.topInset = 2
|
|
329
|
-
leadingBadge.bottomInset = 2
|
|
330
|
-
leadingBadge.layer.cornerRadius = 4
|
|
331
|
-
leadingBadge.clipsToBounds = true
|
|
332
|
-
leadingBadge.accessibilityLabel = badge["accessibilityLabel"] as? String
|
|
333
|
-
leadingBadge.setContentHuggingPriority(.required, for: .horizontal)
|
|
334
|
-
leadingBadge.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
335
|
-
titleLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
|
336
|
-
titleRowStack.insertArrangedSubview(leadingBadge, at: 0)
|
|
337
|
-
}
|
|
338
|
-
if style["titleDecoration"] != nil {
|
|
339
|
-
titleLabel.showsDottedUnderline = style.string("titleDecoration") == "dashed"
|
|
340
|
-
titleLabel.usesDashedUnderline = true
|
|
341
|
-
titleLabel.dottedUnderlineColor = titleLabel.textColor
|
|
342
|
-
}
|
|
343
|
-
let value = accessoryButtons[0]
|
|
344
|
-
if style.string("valuePlacement") == "afterTitle" {
|
|
345
|
-
trailingStack.removeArrangedSubview(value)
|
|
346
|
-
value.removeFromSuperview()
|
|
347
|
-
titleLabel.setContentHuggingPriority(.required, for: .horizontal)
|
|
348
|
-
mainStack.alignment = .leading
|
|
349
|
-
titleRowStack.addArrangedSubview(value)
|
|
350
|
-
}
|
|
351
|
-
if let help = item.data.dictionary("valueHelp") {
|
|
352
|
-
value.showsHelpUnderline = help.string("underline") == "dashed"
|
|
353
|
-
value.isUserInteractionEnabled = help.string("presentation") == "popover"
|
|
354
|
-
accessoryActions = [(help.string("presentation") == "popover" ? help.string("actionKey") : "", nil)]
|
|
355
|
-
value.setNeedsLayout()
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
276
|
private func applyTextStyle(_ item: NativeListItem) {
|
|
359
277
|
let style = item.data.dictionary("style") ?? [:]
|
|
360
278
|
if let title = style.dictionary("title") {
|
|
@@ -394,12 +312,6 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
394
312
|
override func recycleContent() {
|
|
395
313
|
checkboxControl.reset()
|
|
396
314
|
currentItem = nil
|
|
397
|
-
accessoryActions = []
|
|
398
|
-
titleLabel.removeGestureRecognizer(selectorTitleTap)
|
|
399
|
-
titleLabel.isUserInteractionEnabled = false
|
|
400
|
-
accessoryButtons[0].helpBindingGeneration += 1
|
|
401
|
-
accessoryButtons[0].isUserInteractionEnabled = false
|
|
402
|
-
accessoryButtons[0].showsHelpUnderline = false
|
|
403
315
|
titleSpinner.stopAnimating()
|
|
404
316
|
}
|
|
405
317
|
override func didMoveToWindow() {
|