@onekeyfe/react-native-native-list 6.7.0-6 → 6.7.0-60
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 +312 -375
- 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 +50 -13
- 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/NativeListMediaPlaceholderView.kt +244 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +209 -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 +8 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +130 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1978 -136
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListDescriptionTouchPolicyTest.kt +153 -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 +78 -14
- package/docs/SPEC.md +1318 -16
- package/docs/STYLE_SPEC.md +18 -0
- package/ios/HybridNativeList.swift +21 -2
- package/ios/NativeListAccessoryStack.swift +237 -51
- package/ios/NativeListActivityDetailsView.swift +43 -16
- 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/NativeListMediaPlaceholderView.swift +189 -0
- package/ios/NativeListMediaPreviewSlot.swift +122 -61
- package/ios/NativeListMediaTileRenderer.swift +15 -11
- 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 +17 -5
- package/ios/NativeListRowHost.swift +14 -0
- package/ios/NativeListSectionHeaderRenderer.swift +100 -4
- package/ios/NativeListTextLabel.swift +106 -0
- package/ios/RNCNativeListView.swift +1097 -60
- package/ios/tests/NativeListAccessoryStackTests.swift +101 -0
- package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +423 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
- package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
- package/ios/tests/NativeListLifecycleTests.swift +2959 -4
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/ios/tests/NativeListMediaVisibilityTests.swift +27 -1
- package/ios/tests/NativeListSharedIconTests.swift +236 -0
- package/lib/module/NativeList.js +236 -38
- package/lib/module/NativeList.web.js +163 -45
- 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 +1263 -48
- package/lib/module/web/NativeListGeneratedIcons.js +31 -0
- package/lib/module/web/NativeListWebEngine.js +513 -275
- package/lib/module/web/templates/ActivityRowRenderer.js +41 -54
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
- package/lib/module/web/templates/DataRowRenderer.js +56 -5
- package/lib/module/web/templates/IdentityRowRenderer.js +161 -7
- package/lib/module/web/templates/MarketTableRowRenderer.js +36 -19
- package/lib/module/web/templates/MediaTileRowRenderer.js +84 -25
- 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 +134 -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 +439 -91
- package/src/NativeList.types.ts +24 -2
- package/src/NativeList.web.tsx +286 -88
- package/src/index.ts +2 -0
- package/src/models.ts +272 -144
- package/src/selection.ts +1 -0
- package/src/validation.ts +3041 -146
- package/src/web/NativeListGeneratedIcons.ts +28 -0
- package/src/web/NativeListWebEngine.ts +818 -343
- package/src/web/templates/ActivityRowRenderer.ts +71 -91
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +121 -20
- package/src/web/templates/IdentityRowRenderer.ts +234 -9
- package/src/web/templates/MarketTableRowRenderer.ts +53 -33
- package/src/web/templates/MediaTileRowRenderer.ts +90 -28
- 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
package/docs/STYLE_SPEC.md
CHANGED
|
@@ -153,6 +153,7 @@ resolved colors; `style.color` does not resolve application color-token names.
|
|
|
153
153
|
| `bgApp` | `background` | List ground |
|
|
154
154
|
| `bg` | `rowBackground` | Row ground |
|
|
155
155
|
| `bgActive` | `rowSelectedBackground`, `rowPressedBackground` | Selected / pressed row |
|
|
156
|
+
| `bgHover` | `rowHoverBackground` (optional Web) | Hovered row; omission uses pressed color |
|
|
156
157
|
| `bgSubdued` | `subduedBackground` | Card and group ground |
|
|
157
158
|
| `bgStrong` | `strongBackground` | Chip / badge ground |
|
|
158
159
|
| `bgInverse` | `inverseBackground` | Inverted ground |
|
|
@@ -269,6 +270,11 @@ Each cell describes the same public contract on **Web + iOS + Android**.
|
|
|
269
270
|
| `action` | title, value | padding, leadingGap, trailingGap, image |
|
|
270
271
|
| `system` | title, message, actionText | padding, lineGap |
|
|
271
272
|
|
|
273
|
+
`identity.style.leadingContentMaxWidthRatio` optionally caps the leading
|
|
274
|
+
visual, gap and title content to a finite fraction in `(0, 1]` of the row's
|
|
275
|
+
inner width. Omission retains the existing width behavior. This lets a
|
|
276
|
+
same-row trailing text button keep its own space while long titles truncate.
|
|
277
|
+
|
|
272
278
|
Market additionally exposes `titleBadgeLayout: inline`, `contentTrailingGap`,
|
|
273
279
|
`subtitleTrailingPadding`, `changeWidth`, `changeHeight`, `changeCornerRadius`, preserving
|
|
274
280
|
its existing template-specific style surface on every platform.
|
|
@@ -279,6 +285,10 @@ content; `lineGap` separates content text rows (primary/secondary per data colum
|
|
|
279
285
|
for activity, the native failure label or rich title badges; Web has no activity
|
|
280
286
|
badge target);
|
|
281
287
|
`trailingGap` separates trailing values/controls (title/badge to status for rail).
|
|
288
|
+
For identity those are the trailing accessories: a `valuePair` is one accessory,
|
|
289
|
+
so the gap sits between it and its neighbours and never between its two lines,
|
|
290
|
+
on every platform. For activity the gap separates `primaryAmount` from
|
|
291
|
+
`secondaryAmount`.
|
|
282
292
|
`walletGroup` padding applies only to the group; it never cascades into members.
|
|
283
293
|
Composite metric-card `lineGap` separates heading/metric blocks and dividers; it
|
|
284
294
|
does not change the typography or inner label/value gap of each metric.
|
|
@@ -529,6 +539,9 @@ defaults applied when `style` is absent.
|
|
|
529
539
|
| image radius | 10 | 10 | dp(10) | 10px **=** |
|
|
530
540
|
| tile radius | 16 | 16 | 16 | 16px **=** |
|
|
531
541
|
| network badge | 14 | 14×14, r7 | dp(14), circle | 14px, r50% **=** |
|
|
542
|
+
| placeholder glyph | 28% of width, max 44 | CAShapeLayer | Canvas path | inline SVG **=** |
|
|
543
|
+
| loading sheen | 60% wide, -12°, 1.6s | CAKeyframeAnimation | `postInvalidateOnAnimation` | CSS keyframes **=** |
|
|
544
|
+
| failed hatch | 1 / 7, 135°, 4.5% | CAShapeLayer + radial mask | `saveLayer` + `DST_IN` | repeating gradient + mask **=** |
|
|
532
545
|
|
|
533
546
|
### metricCard
|
|
534
547
|
|
|
@@ -629,6 +642,11 @@ the list's general section mechanism.
|
|
|
629
642
|
| Reorder preview | no | — | — | r12, shadow `0 4px 24px` |
|
|
630
643
|
| Reorder count badge | no | 24 h, r12, 12 semibold | dp(24), r dp(12), sp(12) semibold | 24px, r12, 12/22/600 |
|
|
631
644
|
|
|
645
|
+
Pinned section headers draw no separator or shadow on any platform. The pinned
|
|
646
|
+
overlay paints the header's own row background, which is what hides the rows
|
|
647
|
+
scrolling underneath it; a list that wants a visible boundary supplies it through
|
|
648
|
+
the header row's style, not through container chrome.
|
|
649
|
+
|
|
632
650
|
The section index rail is three separate constant sets for one control; Android's
|
|
633
651
|
`sectionIndexDp()` deliberately never follows the source-scale switch.
|
|
634
652
|
|
|
@@ -27,17 +27,22 @@ final class HybridNativeList: HybridNativeListSpec {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
var containerSlotHeightsJson: String = "[]" {
|
|
30
|
+
didSet { if containerSlotHeightsJson != oldValue { slotHeightsChanged = true } }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var sidecarLayoutJson: String = "" {
|
|
30
34
|
didSet {
|
|
31
|
-
guard
|
|
35
|
+
guard sidecarLayoutJson != oldValue else { return }
|
|
32
36
|
runOnMain { [weak self] in
|
|
33
37
|
guard let self else { return }
|
|
34
|
-
self.hostView?.
|
|
38
|
+
self.hostView?.setSidecarLayoutJson(self.sidecarLayoutJson)
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
private var fontsChanged = false
|
|
40
44
|
private var snapshotChanged = false
|
|
45
|
+
private var slotHeightsChanged = false
|
|
41
46
|
|
|
42
47
|
var fontFamiliesJson: String = "{}" {
|
|
43
48
|
didSet { if fontFamiliesJson != oldValue { fontsChanged = true } }
|
|
@@ -75,11 +80,16 @@ final class HybridNativeList: HybridNativeListSpec {
|
|
|
75
80
|
|
|
76
81
|
func afterUpdate() {
|
|
77
82
|
let fonts = fontsChanged ? fontFamiliesJson : nil
|
|
83
|
+
let slotHeights = slotHeightsChanged ? containerSlotHeightsJson : nil
|
|
78
84
|
let snapshot = snapshotChanged ? snapshotJson : nil
|
|
79
85
|
fontsChanged = false
|
|
86
|
+
slotHeightsChanged = false
|
|
80
87
|
snapshotChanged = false
|
|
81
88
|
runOnMain { [weak self] in
|
|
82
89
|
if let fonts { self?.hostView?.setFontFamiliesJson(fonts) }
|
|
90
|
+
if let slotHeights {
|
|
91
|
+
self?.hostView?.setContainerSlotHeightsJson(slotHeights, followedBySnapshot: snapshot != nil)
|
|
92
|
+
}
|
|
83
93
|
if let snapshot { self?.hostView?.applySnapshotJson(snapshot) }
|
|
84
94
|
}
|
|
85
95
|
}
|
|
@@ -109,6 +119,14 @@ final class HybridNativeList: HybridNativeListSpec {
|
|
|
109
119
|
var onSelectionDelta: ((_ payloadJson: String) -> Void)?
|
|
110
120
|
var onReorder: ((_ payloadJson: String) -> Void)?
|
|
111
121
|
var onEndReached: ((_ payloadJson: String) -> Void)?
|
|
122
|
+
var onStructuralTransitionSettled: ((_ payloadJson: String) -> Void)? {
|
|
123
|
+
didSet {
|
|
124
|
+
runOnMain { [weak self] in
|
|
125
|
+
guard let self else { return }
|
|
126
|
+
self.hostView?.onStructuralTransitionSettled = self.onStructuralTransitionSettled
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
112
130
|
var onVisibleRangeChanged: ((_ payloadJson: String) -> Void)? {
|
|
113
131
|
didSet {
|
|
114
132
|
runOnMain { [weak self] in
|
|
@@ -222,6 +240,7 @@ final class HybridNativeList: HybridNativeListSpec {
|
|
|
222
240
|
onSelectionDelta = nil
|
|
223
241
|
onReorder = nil
|
|
224
242
|
onEndReached = nil
|
|
243
|
+
onStructuralTransitionSettled = nil
|
|
225
244
|
onVisibleRangeChanged = nil
|
|
226
245
|
onScrollPositionThresholdChange = nil
|
|
227
246
|
hostView.dispose()
|
|
@@ -1,14 +1,74 @@
|
|
|
1
1
|
import UIKit
|
|
2
2
|
|
|
3
3
|
// OneKey patch: explicit summary actions use the source text's physical-pixel line box.
|
|
4
|
-
final class NativeListAccessoryButton:
|
|
4
|
+
final class NativeListAccessoryButton: NativeListIconButton {
|
|
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
|
|
|
@@ -32,6 +92,13 @@ final class NativeListAccessoryButton: UIButton {
|
|
|
32
92
|
}
|
|
33
93
|
}
|
|
34
94
|
|
|
95
|
+
func clearTitlesForReuse() {
|
|
96
|
+
UIView.performWithoutAnimation {
|
|
97
|
+
super.setAttributedTitle(nil, for: .normal)
|
|
98
|
+
super.setTitle(nil, for: .normal)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
35
102
|
var selectorSummaryLineHeight: CGFloat? {
|
|
36
103
|
didSet {
|
|
37
104
|
invalidateIntrinsicContentSize()
|
|
@@ -52,6 +119,11 @@ final class NativeListAccessoryButton: UIButton {
|
|
|
52
119
|
|
|
53
120
|
override var intrinsicContentSize: CGSize {
|
|
54
121
|
var size = super.intrinsicContentSize
|
|
122
|
+
if let fixedTextLineHeight {
|
|
123
|
+
size.width += 2
|
|
124
|
+
size.height = fixedTextLineHeight + contentEdgeInsets.top + contentEdgeInsets.bottom + 2
|
|
125
|
+
return size
|
|
126
|
+
}
|
|
55
127
|
guard selectorSummaryLineHeight != nil || marketLineHeight != nil,
|
|
56
128
|
let title = attributedTitle(for: .normal)
|
|
57
129
|
else { return size }
|
|
@@ -71,6 +143,10 @@ final class NativeListAccessoryButton: UIButton {
|
|
|
71
143
|
defer {
|
|
72
144
|
if let titleLabel {
|
|
73
145
|
var frame = titleLabel.frame
|
|
146
|
+
if let fixedTextLineHeight {
|
|
147
|
+
frame.size.height = fixedTextLineHeight
|
|
148
|
+
frame.origin.y = (bounds.height - fixedTextLineHeight) / 2
|
|
149
|
+
}
|
|
74
150
|
if contentVerticalAlignment == .top {
|
|
75
151
|
frame.origin.y = contentEdgeInsets.top
|
|
76
152
|
} else if contentVerticalAlignment == .bottom {
|
|
@@ -79,6 +155,7 @@ final class NativeListAccessoryButton: UIButton {
|
|
|
79
155
|
frame.origin.y += rowTextOffsetY
|
|
80
156
|
titleLabel.frame = frame
|
|
81
157
|
}
|
|
158
|
+
layoutHelp()
|
|
82
159
|
}
|
|
83
160
|
if let lineHeight = marketLineHeight, let titleLabel, let title = attributedTitle(for: .normal)
|
|
84
161
|
{
|
|
@@ -120,13 +197,15 @@ final class NativeListAccessoryButton: UIButton {
|
|
|
120
197
|
final class NativeListAccessoryStack: UIStackView {
|
|
121
198
|
var fonts = NativeListFontFamilies()
|
|
122
199
|
private let accessoryButtons = (0..<2).map { _ in NativeListAccessoryButton(type: .system) }
|
|
123
|
-
private let checkboxButton =
|
|
200
|
+
private let checkboxButton = NativeListIconButton(type: .system)
|
|
124
201
|
private let spinner = UIActivityIndicatorView(style: .medium)
|
|
125
202
|
private var accessoryActions: [(String, NativeSelectionTarget?)] = []
|
|
126
203
|
private var checkboxAction: (String, NativeSelectionTarget?)?
|
|
127
204
|
private var boundCheckboxData: [String: Any]?
|
|
128
205
|
private var boundCheckboxTarget: NativeSelectionTarget?
|
|
129
206
|
private var semanticValueButtons: [UIButton] = []
|
|
207
|
+
private var valuePairSubscriptRanges: [ObjectIdentifier: [(NSRange, Bool)]] = [:]
|
|
208
|
+
private var tertiaryIconButtons: Set<ObjectIdentifier> = []
|
|
130
209
|
private var accessorySizeConstraints: [NSLayoutConstraint] = []
|
|
131
210
|
private var currentItem: NativeListItem?
|
|
132
211
|
private var currentTheme: [String: Any]?
|
|
@@ -171,6 +250,8 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
171
250
|
checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String,
|
|
172
251
|
fonts: NativeListFontFamilies
|
|
173
252
|
) {
|
|
253
|
+
let iconUpdate = NativeListIconUpdate(self)
|
|
254
|
+
defer { iconUpdate.finish() }
|
|
174
255
|
self.fonts = fonts
|
|
175
256
|
reset()
|
|
176
257
|
currentItem = item
|
|
@@ -210,14 +291,19 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
210
291
|
}
|
|
211
292
|
}
|
|
212
293
|
func anchorInset(for view: UIView) -> CGFloat {
|
|
213
|
-
|
|
214
|
-
|
|
294
|
+
guard accessoryButtons.contains(where: { $0 === view }), view.bounds.width == 38 else {
|
|
295
|
+
return 0
|
|
296
|
+
}
|
|
297
|
+
if tertiaryIconButtons.contains(ObjectIdentifier(view)) { return 7 }
|
|
298
|
+
return currentItem?.data.string("presentation") == "accountSelector" ? 7 : 0
|
|
215
299
|
}
|
|
216
300
|
func reset() {
|
|
217
301
|
NSLayoutConstraint.deactivate(accessorySizeConstraints)
|
|
218
302
|
accessorySizeConstraints.removeAll()
|
|
219
303
|
accessoryActions.removeAll()
|
|
220
304
|
semanticValueButtons.removeAll()
|
|
305
|
+
valuePairSubscriptRanges.removeAll()
|
|
306
|
+
tertiaryIconButtons.removeAll()
|
|
221
307
|
checkboxAction = nil
|
|
222
308
|
boundCheckboxData = nil
|
|
223
309
|
boundCheckboxTarget = nil
|
|
@@ -225,8 +311,8 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
225
311
|
contentGap = nil
|
|
226
312
|
currentItem = nil
|
|
227
313
|
for (index, button) in accessoryButtons.enumerated() {
|
|
228
|
-
button.
|
|
229
|
-
button.
|
|
314
|
+
button.tag = index
|
|
315
|
+
button.clearTitlesForReuse()
|
|
230
316
|
button.setImage(nil, for: .normal)
|
|
231
317
|
button.setImage(nil, for: .disabled)
|
|
232
318
|
button.titleLabel?.font = nativeListFont(
|
|
@@ -236,14 +322,23 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
236
322
|
button.contentHorizontalAlignment = .center
|
|
237
323
|
button.contentVerticalAlignment = .center
|
|
238
324
|
button.rowTextOffsetY = 0
|
|
325
|
+
button.helpBindingGeneration += 1
|
|
326
|
+
button.helpPrimaryLineOnly = false
|
|
327
|
+
button.showsHelpUnderline = false
|
|
239
328
|
button.transform = .identity
|
|
240
329
|
button.marketLineHeight = nil
|
|
241
330
|
button.selectorSummaryLineHeight = nil
|
|
242
331
|
button.backgroundColor = .clear
|
|
243
332
|
button.pressedBackgroundColor = nil
|
|
333
|
+
button.normalBackgroundColor = .clear
|
|
334
|
+
button.fixedTextLineHeight = nil
|
|
335
|
+
button.contentEdgeInsets = .zero
|
|
336
|
+
button.layer.borderWidth = 0
|
|
337
|
+
button.layer.borderColor = nil
|
|
244
338
|
button.layer.cornerRadius = 0
|
|
245
339
|
button.isHidden = true
|
|
246
340
|
button.isEnabled = true
|
|
341
|
+
button.isUserInteractionEnabled = true
|
|
247
342
|
button.alpha = 1
|
|
248
343
|
button.accessibilityIdentifier = nil
|
|
249
344
|
button.accessibilityLabel = nil
|
|
@@ -253,9 +348,13 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
253
348
|
spinner.alpha = 1
|
|
254
349
|
}
|
|
255
350
|
@objc private func pressed(_ button: UIButton) {
|
|
256
|
-
guard
|
|
257
|
-
|
|
258
|
-
|
|
351
|
+
guard let controlIndex = accessoryButtons.firstIndex(where: { $0 === button }),
|
|
352
|
+
accessoryActions.indices.contains(controlIndex) else { return }
|
|
353
|
+
let action = accessoryActions[controlIndex]
|
|
354
|
+
if !action.0.isEmpty {
|
|
355
|
+
let anchor = accessoryButtons[controlIndex]
|
|
356
|
+
onAction?(action.0, anchor.helpPrimaryLineOnly ? anchor.helpAnchor : button, button.tag, action.1)
|
|
357
|
+
}
|
|
259
358
|
}
|
|
260
359
|
@objc private func checkboxPressed() {
|
|
261
360
|
if let action = checkboxAction { onAction?(action.0, checkboxButton, nil, action.1) }
|
|
@@ -267,8 +366,42 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
267
366
|
_ checkboxState: (NativeListItem, NativeSelectionTarget?, String) -> String
|
|
268
367
|
) {
|
|
269
368
|
var textIndex = 0
|
|
270
|
-
for accessory in accessories.prefix(2) {
|
|
369
|
+
for (slot, accessory) in accessories.prefix(2).enumerated() {
|
|
370
|
+
let controlIndex = textIndex
|
|
271
371
|
switch accessory.string("kind") {
|
|
372
|
+
case "button":
|
|
373
|
+
showAccessory(
|
|
374
|
+
textIndex, accessory.string("label"),
|
|
375
|
+
action: accessory.bool("disabled") || item.data.bool("disabled")
|
|
376
|
+
? nil : (accessory.string("actionKey"), nil))
|
|
377
|
+
let button = accessoryButtons[textIndex]
|
|
378
|
+
button.titleLabel?.font = nativeListFont(ofSize: 14, weight: .medium, fonts: fonts)
|
|
379
|
+
button.fixedTextLineHeight = 20
|
|
380
|
+
button.contentEdgeInsets = UIEdgeInsets(top: 4, left: 10, bottom: 4, right: 10)
|
|
381
|
+
button.layer.borderWidth = 1
|
|
382
|
+
button.layer.borderColor = UIColor.clear.cgColor
|
|
383
|
+
button.layer.cornerRadius = 15
|
|
384
|
+
button.backgroundColor = UIColor(
|
|
385
|
+
nativeListHex: accessory.string("backgroundColor",
|
|
386
|
+
default: theme?["strongBackground"] as? String ?? "#F0F0F0"),
|
|
387
|
+
fallback: .clear)
|
|
388
|
+
button.normalBackgroundColor = button.backgroundColor ?? .clear
|
|
389
|
+
button.pressedBackgroundColor = UIColor(
|
|
390
|
+
nativeListHex: accessory.string("pressedBackgroundColor",
|
|
391
|
+
default: theme?["rowPressedBackground"] as? String ?? "#E4E4E4"),
|
|
392
|
+
fallback: .clear)
|
|
393
|
+
button.setTitleColor(
|
|
394
|
+
UIColor(
|
|
395
|
+
nativeListHex: accessory.string("textColor",
|
|
396
|
+
default: theme?["primaryText"] as? String ?? "#202020"),
|
|
397
|
+
fallback: .darkGray),
|
|
398
|
+
for: .normal)
|
|
399
|
+
button.accessibilityIdentifier = accessory.string("testID")
|
|
400
|
+
button.accessibilityLabel =
|
|
401
|
+
accessory.string("accessibilityLabel", default: accessory.string("label"))
|
|
402
|
+
button.isEnabled = !item.data.bool("disabled") && !accessory.bool("disabled")
|
|
403
|
+
button.alpha = button.isEnabled ? 1 : 0.4
|
|
404
|
+
textIndex += 1
|
|
272
405
|
case "value":
|
|
273
406
|
showAccessory(textIndex, accessory.string("text"))
|
|
274
407
|
semanticValueButtons.append(accessoryButtons[textIndex])
|
|
@@ -325,6 +458,7 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
325
458
|
textIndex += 1
|
|
326
459
|
default: break
|
|
327
460
|
}
|
|
461
|
+
if textIndex > controlIndex { accessoryButtons[controlIndex].tag = slot }
|
|
328
462
|
}
|
|
329
463
|
}
|
|
330
464
|
|
|
@@ -369,10 +503,7 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
369
503
|
state == "indeterminate"
|
|
370
504
|
? "CheckboxIndeterminateCustom"
|
|
371
505
|
: "CheckboxCheckedCustom"
|
|
372
|
-
checkboxButton.
|
|
373
|
-
state == "unchecked" ? nil : nativeListIcon(named: glyphName),
|
|
374
|
-
for: .normal
|
|
375
|
-
)
|
|
506
|
+
checkboxButton.bindIcon(state == "unchecked" ? nil : glyphName)
|
|
376
507
|
checkboxButton.tintColor = checkboxIconColor
|
|
377
508
|
// A disabled ListItem already applies 0.5 to its complete content. Avoid
|
|
378
509
|
// multiplying that opacity on the nested control a second time.
|
|
@@ -391,6 +522,11 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
391
522
|
guard accessoryButtons.indices.contains(index), !value.isEmpty else { return }
|
|
392
523
|
let button = accessoryButtons[index]
|
|
393
524
|
button.isHidden = false
|
|
525
|
+
// A text accessory without an action is display only. As an enabled
|
|
526
|
+
// UIControl it still claimed the touch, so a tap on a row value such as
|
|
527
|
+
// a network balance never reached the cell and the row did not select
|
|
528
|
+
// (OK-65494). Let those touches fall through to the row press.
|
|
529
|
+
button.isUserInteractionEnabled = action != nil
|
|
394
530
|
button.setTitle(value, for: .normal)
|
|
395
531
|
button.setContentHuggingPriority(.required, for: .horizontal)
|
|
396
532
|
button.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
@@ -405,54 +541,81 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
405
541
|
theme: [String: Any]?
|
|
406
542
|
) {
|
|
407
543
|
guard accessoryButtons.indices.contains(index) else { return }
|
|
408
|
-
let
|
|
409
|
-
let
|
|
544
|
+
let primarySegments = accessory.dictionaries("primaryTextSegments")
|
|
545
|
+
let secondarySegments = accessory.dictionaries("secondaryTextSegments")
|
|
546
|
+
let primary = primarySegments.isEmpty
|
|
547
|
+
? accessory.string("primary") : primarySegments.map { $0.string("text") }.joined()
|
|
548
|
+
let secondary = secondarySegments.isEmpty
|
|
549
|
+
? accessory.string("secondary") : secondarySegments.map { $0.string("text") }.joined()
|
|
410
550
|
guard !primary.isEmpty || !secondary.isEmpty else { return }
|
|
411
551
|
let button = accessoryButtons[index]
|
|
552
|
+
// Value pairs never carry an action; the row owns their touches.
|
|
553
|
+
button.isUserInteractionEnabled = false
|
|
412
554
|
let text = NSMutableAttributedString()
|
|
413
555
|
let primaryParagraph = NSMutableParagraphStyle()
|
|
414
556
|
primaryParagraph.alignment = .right
|
|
415
557
|
primaryParagraph.minimumLineHeight = 20
|
|
416
558
|
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
|
-
))
|
|
559
|
+
var subscriptRanges: [(NSRange, Bool)] = []
|
|
560
|
+
appendValuePairLine(
|
|
561
|
+
to: text, fallback: primary, segments: primarySegments, fontSize: 16,
|
|
562
|
+
weight: .medium,
|
|
563
|
+
color: accessoryTextColor(accessory.string("primaryTone"), defaultTone: "primary", theme: theme),
|
|
564
|
+
paragraph: primaryParagraph, isPrimary: true, subscriptRanges: &subscriptRanges)
|
|
430
565
|
if !primary.isEmpty, !secondary.isEmpty { text.append(NSAttributedString(string: "\n")) }
|
|
431
566
|
let secondaryParagraph = NSMutableParagraphStyle()
|
|
432
567
|
secondaryParagraph.alignment = .right
|
|
433
568
|
secondaryParagraph.minimumLineHeight = 20
|
|
434
569
|
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
|
-
))
|
|
570
|
+
appendValuePairLine(
|
|
571
|
+
to: text, fallback: secondary, segments: secondarySegments, fontSize: 14,
|
|
572
|
+
weight: .regular,
|
|
573
|
+
color: accessoryTextColor(accessory.string("secondaryTone"), defaultTone: "secondary", theme: theme),
|
|
574
|
+
paragraph: secondaryParagraph, isPrimary: false, subscriptRanges: &subscriptRanges)
|
|
448
575
|
button.isHidden = false
|
|
449
576
|
button.titleLabel?.numberOfLines = 2
|
|
450
577
|
button.contentHorizontalAlignment = .trailing
|
|
451
578
|
button.setAttributedTitle(text, for: .normal)
|
|
579
|
+
valuePairSubscriptRanges[ObjectIdentifier(button)] = subscriptRanges
|
|
452
580
|
button.setContentHuggingPriority(.required, for: .horizontal)
|
|
453
581
|
button.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
454
582
|
while accessoryActions.count <= index { accessoryActions.append(("", nil)) }
|
|
455
583
|
accessoryActions[index] = ("", nil)
|
|
584
|
+
if let help = accessory.dictionary("primaryHelp") {
|
|
585
|
+
button.helpPrimaryLineOnly = true
|
|
586
|
+
button.showsHelpUnderline = help.string("underline") == "dashed"
|
|
587
|
+
button.isUserInteractionEnabled = help.string("presentation") == "popover"
|
|
588
|
+
accessoryActions[index] = (help.string("presentation") == "popover" ? help.string("actionKey") : "", nil)
|
|
589
|
+
button.setNeedsLayout()
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
private func appendValuePairLine(
|
|
594
|
+
to text: NSMutableAttributedString,
|
|
595
|
+
fallback: String,
|
|
596
|
+
segments: [[String: Any]],
|
|
597
|
+
fontSize: CGFloat,
|
|
598
|
+
weight: NativeListFontWeight,
|
|
599
|
+
color: UIColor,
|
|
600
|
+
paragraph: NSParagraphStyle,
|
|
601
|
+
isPrimary: Bool,
|
|
602
|
+
subscriptRanges: inout [(NSRange, Bool)]
|
|
603
|
+
) {
|
|
604
|
+
let runs = segments.isEmpty ? [["text": fallback]] : segments
|
|
605
|
+
for run in runs {
|
|
606
|
+
let content = run.string("text")
|
|
607
|
+
let isSubscript = run.string("style") == "subscript"
|
|
608
|
+
let start = text.length
|
|
609
|
+
text.append(NSAttributedString(string: content, attributes: [
|
|
610
|
+
.font: nativeListFont(
|
|
611
|
+
ofSize: isSubscript ? ceil(fontSize * 0.6) : fontSize, weight: weight, fonts: fonts),
|
|
612
|
+
.foregroundColor: color,
|
|
613
|
+
.paragraphStyle: paragraph,
|
|
614
|
+
]))
|
|
615
|
+
if isSubscript && text.length > start {
|
|
616
|
+
subscriptRanges.append((NSRange(location: start, length: text.length - start), isPrimary))
|
|
617
|
+
}
|
|
618
|
+
}
|
|
456
619
|
}
|
|
457
620
|
|
|
458
621
|
private func showMenuAccessory(
|
|
@@ -500,16 +663,26 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
500
663
|
? nativeListColor(currentTheme, "iconSubdued", "#8D8D8D")
|
|
501
664
|
: UIColor(nativeListHex: data.string("tintColor", default: "#646464"), fallback: .darkGray)
|
|
502
665
|
button.tintColor = tintColor
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
image.withTintColor(tintColor, renderingMode: .alwaysOriginal),
|
|
507
|
-
for: .disabled
|
|
508
|
-
)
|
|
509
|
-
}
|
|
666
|
+
let isDecorativeRefresh =
|
|
667
|
+
data.string("name") == "RefreshCcwOutline" && data.string("actionKey").isEmpty
|
|
668
|
+
button.bindIcon(data.string("name"), size: isDecorativeRefresh ? CGSize(width: 16, height: 16) : nil)
|
|
510
669
|
let isDrillIn = data.string("kind") == "chevron"
|
|
670
|
+
let isTertiary = data.string("buttonStyle") == "tertiary"
|
|
671
|
+
if data.string("kind") == "icon" && isTertiary {
|
|
672
|
+
tertiaryIconButtons.insert(ObjectIdentifier(button))
|
|
673
|
+
}
|
|
511
674
|
let isAccountIcon = currentItem?.data.string("presentation") == "accountSelector" && !isDrillIn
|
|
512
|
-
|
|
675
|
+
button.isUserInteractionEnabled = !isDecorativeRefresh
|
|
676
|
+
let size: CGFloat =
|
|
677
|
+
isDecorativeRefresh ? 16 : isDrillIn ? 24 : isTertiary || isAccountIcon && !isAccountCreate ? 38 : 36
|
|
678
|
+
if isTertiary {
|
|
679
|
+
button.pressedBackgroundColor = nativeListColor(
|
|
680
|
+
currentTheme, "rowPressedBackground", "#E8E8E8")
|
|
681
|
+
button.layer.borderWidth = 1
|
|
682
|
+
button.layer.borderColor = UIColor.clear.cgColor
|
|
683
|
+
button.layer.cornerRadius = 19
|
|
684
|
+
button.contentEdgeInsets = UIEdgeInsets(top: 6, left: 6, bottom: 6, right: 6)
|
|
685
|
+
}
|
|
513
686
|
if isAccountCreate { button.layer.cornerRadius = 8 }
|
|
514
687
|
if isAccountIcon && !isAccountCreate && !data.string("actionKey").isEmpty {
|
|
515
688
|
button.pressedBackgroundColor = nativeListColor(
|
|
@@ -647,6 +820,19 @@ final class NativeListAccessoryStack: UIStackView {
|
|
|
647
820
|
}
|
|
648
821
|
button.titleLabel?.font = font
|
|
649
822
|
attributed.addAttributes(attributes, range: NSRange(location: 0, length: attributed.length))
|
|
823
|
+
if style["fontSize"] != nil,
|
|
824
|
+
let ranges = valuePairSubscriptRanges[ObjectIdentifier(button)]
|
|
825
|
+
{
|
|
826
|
+
for (range, isPrimary) in ranges {
|
|
827
|
+
let weight = style["fontWeight"] == nil
|
|
828
|
+
? (isPrimary ? NativeListFontWeight.medium : NativeListFontWeight.regular)
|
|
829
|
+
: marketFontWeight(style.string("fontWeight"), fallback: .regular)
|
|
830
|
+
attributed.addAttribute(
|
|
831
|
+
.font,
|
|
832
|
+
value: nativeListFont(ofSize: ceil(size * 0.6), weight: weight, fonts: fonts),
|
|
833
|
+
range: range)
|
|
834
|
+
}
|
|
835
|
+
}
|
|
650
836
|
button.setAttributedTitle(attributed, for: .normal)
|
|
651
837
|
}
|
|
652
838
|
|