@onekeyfe/react-native-native-list 6.7.0-3 → 6.7.0-30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +250 -9
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +35 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListGeneratedIcons.kt +47 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +152 -33
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +1 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +149 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +120 -287
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +7 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1953 -117
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
- package/docs/ROW_TEMPLATES.md +70 -11
- package/docs/SPEC.md +1170 -13
- package/docs/STYLE_SPEC.md +11 -0
- package/ios/HybridNativeList.swift +21 -2
- package/ios/NativeListAccessoryStack.swift +237 -51
- package/ios/NativeListActivityDetailsView.swift +30 -11
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +167 -30
- package/ios/NativeListDesignAssets.swift +13 -75
- package/ios/NativeListGeneratedIcons.swift +55 -0
- package/ios/NativeListIconBinding.swift +171 -0
- package/ios/NativeListIdentityRenderer.swift +256 -39
- package/ios/NativeListLeadingVisual.swift +127 -28
- package/ios/NativeListMarketRenderer.swift +120 -31
- package/ios/NativeListMediaPreviewSlot.swift +122 -61
- package/ios/NativeListMediaTileRenderer.swift +7 -3
- package/ios/NativeListMessageRenderer.swift +34 -1
- package/ios/NativeListMetricCardRenderer.swift +4 -2
- package/ios/NativeListModels.swift +42 -2
- package/ios/NativeListRendererRegistry.swift +1 -0
- package/ios/NativeListResolvedText.swift +2 -1
- package/ios/NativeListRowHost.swift +14 -0
- package/ios/NativeListSectionHeaderRenderer.swift +100 -4
- package/ios/RNCNativeListView.swift +1052 -58
- package/ios/tests/NativeListAccessoryStackTests.swift +101 -0
- package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +153 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
- package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
- package/ios/tests/NativeListLifecycleTests.swift +2798 -3
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/ios/tests/NativeListMediaVisibilityTests.swift +26 -1
- package/ios/tests/NativeListSharedIconTests.swift +236 -0
- package/lib/module/NativeList.js +221 -36
- package/lib/module/NativeList.web.js +167 -46
- package/lib/module/index.js +1 -1
- package/lib/module/models.js +3 -0
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +1246 -48
- package/lib/module/web/NativeListGeneratedIcons.js +31 -0
- package/lib/module/web/NativeListWebEngine.js +513 -274
- package/lib/module/web/templates/ActivityRowRenderer.js +120 -87
- 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 +158 -6
- package/lib/module/web/templates/MarketTableRowRenderer.js +37 -19
- package/lib/module/web/templates/MediaTileRowRenderer.js +4 -14
- 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 +26 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/lib/typescript/src/NativeList.d.ts +3 -3
- package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
- package/lib/typescript/src/NativeList.types.d.ts +20 -2
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +126 -17
- package/lib/typescript/src/validation.d.ts +20 -0
- package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +2 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +32 -1
- 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 +26 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/package.json +16 -10
- package/react-native-native-list.podspec +2 -6
- package/scripts/generate-icons.mjs +150 -0
- package/scripts/generate-icons.test.mjs +288 -0
- package/scripts/native-list-icons.json +260 -0
- package/src/NativeList.nitro.ts +2 -0
- package/src/NativeList.tsx +416 -89
- package/src/NativeList.types.ts +24 -2
- package/src/NativeList.web.tsx +295 -89
- package/src/index.ts +2 -0
- package/src/models.ts +263 -144
- package/src/selection.ts +1 -0
- package/src/validation.ts +3013 -152
- package/src/web/NativeListGeneratedIcons.ts +28 -0
- package/src/web/NativeListWebEngine.ts +816 -343
- package/src/web/templates/ActivityRowRenderer.ts +178 -141
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +93 -20
- package/src/web/templates/IdentityRowRenderer.ts +231 -6
- package/src/web/templates/MarketTableRowRenderer.ts +56 -33
- package/src/web/templates/MediaTileRowRenderer.ts +4 -17
- 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
- package/ios/Resources/NativeListIcons.xcassets/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/icon.svg +0 -14
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/icon.svg +0 -12
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/icon.svg +0 -6
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/icon.svg +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/icon.svg +0 -3
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/icon.svg +0 -18
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +0 -1
|
@@ -1,6 +1,13 @@
|
|
|
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
|
+
}
|
|
4
11
|
var showsDottedUnderline = false {
|
|
5
12
|
didSet { setNeedsLayout() }
|
|
6
13
|
}
|
|
@@ -111,13 +118,14 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
111
118
|
private let mainStack = UIStackView()
|
|
112
119
|
private let titleRowStack = UIStackView()
|
|
113
120
|
private let titleLabel = NativeListDottedUnderlineLabel()
|
|
121
|
+
private let leadingBadge = NativeListInsetLabel()
|
|
114
122
|
private let titleSpinner = UIActivityIndicatorView(style: .medium)
|
|
115
123
|
private let subtitleLabel = NativeListTextLabel()
|
|
116
124
|
private let trailingStack = UIStackView()
|
|
117
125
|
private let accessoryButtons = [NativeListAccessoryButton(type: .system)]
|
|
118
126
|
private let checkboxControl = NativeListAccessoryStack(frame: .zero)
|
|
119
|
-
private let headerTitleIconImageView =
|
|
120
|
-
private let headerValueIconImageView =
|
|
127
|
+
private let headerTitleIconImageView = NativeListIconImageView()
|
|
128
|
+
private let headerValueIconImageView = NativeListIconImageView()
|
|
121
129
|
private var accessoryActions: [(String, NativeSelectionTarget?)] = []
|
|
122
130
|
private var currentItem: NativeListItem?
|
|
123
131
|
private var currentTheme: [String: Any]?
|
|
@@ -148,6 +156,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
148
156
|
titleRowStack.axis = .horizontal
|
|
149
157
|
titleRowStack.alignment = .center
|
|
150
158
|
titleRowStack.spacing = 8
|
|
159
|
+
leadingBadge.heightAnchor.constraint(equalToConstant: 20).isActive = true
|
|
151
160
|
titleRowStack.addArrangedSubview(titleLabel)
|
|
152
161
|
mainStack.addArrangedSubview(titleRowStack)
|
|
153
162
|
mainStack.addArrangedSubview(subtitleLabel)
|
|
@@ -178,10 +187,22 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
178
187
|
_ item: NativeListItem, theme: [String: Any]?, layout: String,
|
|
179
188
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
180
189
|
) {
|
|
190
|
+
let iconUpdate = NativeListIconUpdate(self)
|
|
191
|
+
defer { iconUpdate.finish() }
|
|
192
|
+
|
|
181
193
|
selectorTypographyRestorers.reversed().forEach { $0() }
|
|
182
194
|
selectorTypographyRestorers = []
|
|
183
195
|
currentItem = item
|
|
184
196
|
currentTheme = theme
|
|
197
|
+
if accessoryButtons[0].superview === titleRowStack {
|
|
198
|
+
titleRowStack.removeArrangedSubview(accessoryButtons[0])
|
|
199
|
+
accessoryButtons[0].removeFromSuperview()
|
|
200
|
+
trailingStack.insertArrangedSubview(accessoryButtons[0], at: 0)
|
|
201
|
+
}
|
|
202
|
+
titleRowStack.removeArrangedSubview(leadingBadge)
|
|
203
|
+
leadingBadge.removeFromSuperview()
|
|
204
|
+
leadingBadge.text = nil
|
|
205
|
+
leadingBadge.accessibilityLabel = nil
|
|
185
206
|
titleSpinner.stopAnimating()
|
|
186
207
|
NSLayoutConstraint.deactivate(selectorConstraints)
|
|
187
208
|
selectorConstraints = []
|
|
@@ -198,6 +219,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
198
219
|
titleLabel.removeGestureRecognizer(selectorTitleTap)
|
|
199
220
|
titleLabel.isUserInteractionEnabled = false
|
|
200
221
|
titleLabel.showsDottedUnderline = false
|
|
222
|
+
titleLabel.usesDashedUnderline = false
|
|
201
223
|
titleLabel.reservesDottedUnderlineSpace = false
|
|
202
224
|
titleLabel.dottedUnderlineVerticalOffset = 0
|
|
203
225
|
for label in [titleLabel, subtitleLabel] {
|
|
@@ -211,6 +233,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
211
233
|
label.rowVerticalAlignment = nil
|
|
212
234
|
}
|
|
213
235
|
titleLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
|
236
|
+
titleLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
214
237
|
subtitleLabel.font = nativeListFont(ofSize: 14, fonts: fonts)
|
|
215
238
|
subtitleLabel.textColor = nativeListColor(theme, "secondaryText", "#646464")
|
|
216
239
|
mainStack.alignment = .fill
|
|
@@ -228,6 +251,10 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
228
251
|
value.contentHorizontalAlignment = .center
|
|
229
252
|
value.contentVerticalAlignment = .center
|
|
230
253
|
value.rowTextOffsetY = 0
|
|
254
|
+
value.helpBindingGeneration += 1
|
|
255
|
+
value.helpPrimaryLineOnly = false
|
|
256
|
+
value.showsHelpUnderline = false
|
|
257
|
+
value.isUserInteractionEnabled = true
|
|
231
258
|
value.marketLineHeight = nil
|
|
232
259
|
value.selectorSummaryLineHeight = nil
|
|
233
260
|
value.isHidden = true
|
|
@@ -253,6 +280,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
253
280
|
if style["lineGap"] != nil { mainStack.spacing = CGFloat(style.double("lineGap")) }
|
|
254
281
|
if style["trailingGap"] != nil { trailingStack.spacing = CGFloat(style.double("trailingGap")) }
|
|
255
282
|
applyTextStyle(item)
|
|
283
|
+
bindPositionHeaderFields(item, theme: theme)
|
|
256
284
|
titleSpinner.color = titleLabel.textColor
|
|
257
285
|
updateTitleSpinner()
|
|
258
286
|
contentInsets = UIEdgeInsets(
|
|
@@ -272,6 +300,64 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
272
300
|
width.isActive = true
|
|
273
301
|
selectorConstraints.append(width)
|
|
274
302
|
}
|
|
303
|
+
|
|
304
|
+
}
|
|
305
|
+
private func bindPositionHeaderFields(_ item: NativeListItem, theme: [String: Any]?) {
|
|
306
|
+
let style = item.data.dictionary("style") ?? [:]
|
|
307
|
+
if let badge = item.data.dictionary("leadingBadge") {
|
|
308
|
+
leadingBadge.text = badge.string("text")
|
|
309
|
+
leadingBadge.font = nativeListFont(ofSize: 12, weight: .medium, fonts: fonts)
|
|
310
|
+
let tones = ["info": ("info", "#0F69F6"), "success": ("positive", "#008F5A"), "warning": ("caution", "#A35E00"), "danger": ("negative", "#CE2C31")]
|
|
311
|
+
if let tone = tones[badge.string("tone")] {
|
|
312
|
+
let color = nativeListColor(theme, tone.0, tone.1)
|
|
313
|
+
leadingBadge.textColor = color
|
|
314
|
+
leadingBadge.backgroundColor = color.withAlphaComponent(0.12)
|
|
315
|
+
if badge.string("tone") == "success", let background = theme?["successBackground"] as? String {
|
|
316
|
+
leadingBadge.backgroundColor = UIColor(nativeListHex: background, fallback: color.withAlphaComponent(0.12))
|
|
317
|
+
}
|
|
318
|
+
} else {
|
|
319
|
+
leadingBadge.textColor = nativeListColor(theme, "secondaryText", "#646464")
|
|
320
|
+
leadingBadge.backgroundColor = nativeListColor(theme, "strongBackground", "#F0F0F0")
|
|
321
|
+
}
|
|
322
|
+
let paragraph = NSMutableParagraphStyle()
|
|
323
|
+
paragraph.minimumLineHeight = 16
|
|
324
|
+
paragraph.maximumLineHeight = 16
|
|
325
|
+
leadingBadge.attributedText = NSAttributedString(
|
|
326
|
+
string: badge.string("text"), attributes: [
|
|
327
|
+
.font: leadingBadge.font as Any,
|
|
328
|
+
.foregroundColor: leadingBadge.textColor as Any,
|
|
329
|
+
.paragraphStyle: paragraph,
|
|
330
|
+
])
|
|
331
|
+
leadingBadge.horizontalInset = 8
|
|
332
|
+
leadingBadge.topInset = 2
|
|
333
|
+
leadingBadge.bottomInset = 2
|
|
334
|
+
leadingBadge.layer.cornerRadius = 4
|
|
335
|
+
leadingBadge.clipsToBounds = true
|
|
336
|
+
leadingBadge.accessibilityLabel = badge["accessibilityLabel"] as? String
|
|
337
|
+
leadingBadge.setContentHuggingPriority(.required, for: .horizontal)
|
|
338
|
+
leadingBadge.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
339
|
+
titleLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
|
340
|
+
titleRowStack.insertArrangedSubview(leadingBadge, at: 0)
|
|
341
|
+
}
|
|
342
|
+
if style["titleDecoration"] != nil {
|
|
343
|
+
titleLabel.showsDottedUnderline = style.string("titleDecoration") == "dashed"
|
|
344
|
+
titleLabel.usesDashedUnderline = true
|
|
345
|
+
titleLabel.dottedUnderlineColor = titleLabel.textColor
|
|
346
|
+
}
|
|
347
|
+
let value = accessoryButtons[0]
|
|
348
|
+
if style.string("valuePlacement") == "afterTitle" {
|
|
349
|
+
trailingStack.removeArrangedSubview(value)
|
|
350
|
+
value.removeFromSuperview()
|
|
351
|
+
titleLabel.setContentHuggingPriority(.required, for: .horizontal)
|
|
352
|
+
mainStack.alignment = .leading
|
|
353
|
+
titleRowStack.addArrangedSubview(value)
|
|
354
|
+
}
|
|
355
|
+
if let help = item.data.dictionary("valueHelp") {
|
|
356
|
+
value.showsHelpUnderline = help.string("underline") == "dashed"
|
|
357
|
+
value.isUserInteractionEnabled = help.string("presentation") == "popover"
|
|
358
|
+
accessoryActions = [(help.string("presentation") == "popover" ? help.string("actionKey") : "", nil)]
|
|
359
|
+
value.setNeedsLayout()
|
|
360
|
+
}
|
|
275
361
|
}
|
|
276
362
|
private func applyTextStyle(_ item: NativeListItem) {
|
|
277
363
|
let style = item.data.dictionary("style") ?? [:]
|
|
@@ -289,6 +375,9 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
289
375
|
_ item: NativeListItem,
|
|
290
376
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
291
377
|
) {
|
|
378
|
+
let iconUpdate = NativeListIconUpdate(self)
|
|
379
|
+
defer { iconUpdate.finish() }
|
|
380
|
+
|
|
292
381
|
currentItem = item
|
|
293
382
|
checkboxControl.updateSelection(item, checkboxState: checkboxState)
|
|
294
383
|
if item.data.string("variant") == "summary" {
|
|
@@ -300,6 +389,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
300
389
|
applyTextStyle(item)
|
|
301
390
|
applySelectorTypography(item)
|
|
302
391
|
}
|
|
392
|
+
|
|
303
393
|
}
|
|
304
394
|
private func bindCheckbox(
|
|
305
395
|
_ item: NativeListItem, _ descriptor: [String: Any],
|
|
@@ -312,6 +402,12 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
312
402
|
override func recycleContent() {
|
|
313
403
|
checkboxControl.reset()
|
|
314
404
|
currentItem = nil
|
|
405
|
+
accessoryActions = []
|
|
406
|
+
titleLabel.removeGestureRecognizer(selectorTitleTap)
|
|
407
|
+
titleLabel.isUserInteractionEnabled = false
|
|
408
|
+
accessoryButtons[0].helpBindingGeneration += 1
|
|
409
|
+
accessoryButtons[0].isUserInteractionEnabled = false
|
|
410
|
+
accessoryButtons[0].showsHelpUnderline = false
|
|
315
411
|
titleSpinner.stopAnimating()
|
|
316
412
|
}
|
|
317
413
|
override func didMoveToWindow() {
|
|
@@ -435,7 +531,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
435
531
|
topInset = 12
|
|
436
532
|
bottomInset = -2
|
|
437
533
|
if let icon = item.data.dictionary("titleIcon") {
|
|
438
|
-
headerTitleIconImageView.
|
|
534
|
+
headerTitleIconImageView.bindIcon(icon.string("name"))
|
|
439
535
|
headerTitleIconImageView.tintColor = UIColor(
|
|
440
536
|
nativeListHex: icon.string("tintColor", default: "#646464"),
|
|
441
537
|
fallback: .darkGray
|
|
@@ -505,7 +601,7 @@ final class NativeListSectionHeaderCell: NativeListRendererCell {
|
|
|
505
601
|
for: .normal
|
|
506
602
|
)
|
|
507
603
|
if let icon = item.data.dictionary("valueIcon") {
|
|
508
|
-
headerValueIconImageView.
|
|
604
|
+
headerValueIconImageView.bindIcon(icon.string("name"))
|
|
509
605
|
headerValueIconImageView.tintColor = UIColor(
|
|
510
606
|
nativeListHex: icon.string("tintColor", default: "#646464"),
|
|
511
607
|
fallback: .darkGray
|