@onekeyfe/react-native-native-list 6.7.0-alpha.412 → 6.7.0-alpha.414
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/NativeListAccessoryStack.kt +0 -5
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +0 -5
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +338 -117
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +0 -5
- package/docs/SPEC.md +7 -114
- package/ios/NativeListAccessoryStack.swift +16 -6
- package/ios/NativeListDataRowRenderer.swift +6 -15
- package/ios/NativeListDesignAssets.swift +84 -13
- package/ios/NativeListIdentityRenderer.swift +10 -12
- package/ios/NativeListLeadingVisual.swift +9 -11
- package/ios/NativeListMarketRenderer.swift +13 -7
- package/ios/NativeListMediaTileRenderer.swift +2 -6
- package/ios/NativeListMetricCardRenderer.swift +2 -4
- package/ios/NativeListSectionHeaderRenderer.swift +4 -12
- package/ios/Resources/NativeListIcons.xcassets/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_crypto_coin_outline.imageset/icon.svg +4 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_document2.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_ver_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_gas_solid.imageset/icon.svg +3 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_large.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_refresh_ccw_outline.imageset/icon.svg +3 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/icon.svg +14 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/icon.svg +12 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/icon.svg +6 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/icon.svg +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/icon.svg +3 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/icon.svg +7 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/icon.svg +18 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/Contents.json +15 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/icon.svg +7 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_ticket.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_wallet.imageset/icon.svg +1 -0
- package/ios/tests/NativeListAccessoryStackTests.swift +0 -12
- package/lib/module/web/NativeListWebEngine.js +323 -21
- package/lib/module/web/templates/ActivityRowRenderer.js +24 -4
- package/lib/module/web/templates/MarketTableRowRenderer.js +15 -11
- package/lib/module/web/templates/MediaTileRowRenderer.js +12 -2
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +1 -0
- package/package.json +4 -10
- package/react-native-native-list.podspec +5 -0
- package/src/web/NativeListWebEngine.ts +405 -25
- package/src/web/templates/ActivityRowRenderer.ts +53 -15
- package/src/web/templates/MarketTableRowRenderer.ts +29 -17
- package/src/web/templates/MediaTileRowRenderer.ts +15 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListGeneratedIcons.kt +0 -47
- package/ios/NativeListGeneratedIcons.swift +0 -55
- package/ios/NativeListIconBinding.swift +0 -171
- package/ios/tests/NativeListSharedIconTests.swift +0 -236
- package/lib/module/web/NativeListGeneratedIcons.js +0 -31
- package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +0 -2
- package/scripts/generate-icons.mjs +0 -150
- package/scripts/generate-icons.test.mjs +0 -288
- package/scripts/native-list-icons.json +0 -260
- package/src/web/NativeListGeneratedIcons.ts +0 -28
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// Generated by scripts/generate-icons.mjs. Coverage and legacy names only; hosts provide SVG resources.
|
|
2
|
-
package com.margelo.nitro.nativelist
|
|
3
|
-
|
|
4
|
-
internal data class NativeListIconMetadata(val name: String, val width: Float, val height: Float)
|
|
5
|
-
internal val nativeListGeneratedIcons: Map<String, NativeListIconMetadata> = mapOf(
|
|
6
|
-
"AccountErrorCustom" to NativeListIconMetadata("AccountErrorCustom", 18f, 18f),
|
|
7
|
-
"AllNetworksSolid" to NativeListIconMetadata("AllNetworksSolid", 24f, 24f),
|
|
8
|
-
"AppleBrand" to NativeListIconMetadata("AppleBrand", 16f, 20f),
|
|
9
|
-
"ArrowBottomOutline" to NativeListIconMetadata("ArrowBottomOutline", 24f, 24f),
|
|
10
|
-
"ArrowTopOutline" to NativeListIconMetadata("ArrowTopOutline", 24f, 24f),
|
|
11
|
-
"BadgeVerifiedSolid" to NativeListIconMetadata("BadgeRecognizedSolid", 24f, 24f),
|
|
12
|
-
"BotIllus" to NativeListIconMetadata("BotIllus", 24f, 24f),
|
|
13
|
-
"ChartTrendingUpOutline" to NativeListIconMetadata("ChartTrendingUpOutline", 24f, 24f),
|
|
14
|
-
"ChevronBottomOutline" to NativeListIconMetadata("ChevronBottomOutline", 24f, 24f),
|
|
15
|
-
"ChevronGrabberVerOutline" to NativeListIconMetadata("ChevronGrabberVerOutline", 24f, 24f),
|
|
16
|
-
"ChevronRightSmallOutline" to NativeListIconMetadata("ChevronRightSmallOutline", 24f, 24f),
|
|
17
|
-
"ChevronTopOutline" to NativeListIconMetadata("ChevronTopOutline", 24f, 24f),
|
|
18
|
-
"Circle" to NativeListIconMetadata("Circle", 24f, 24f),
|
|
19
|
-
"CrossedSmallSolid" to NativeListIconMetadata("CrossedSmallSolid", 24f, 24f),
|
|
20
|
-
"CryptoCoinOutline" to NativeListIconMetadata("CryptoCoinOutline", 24f, 24f),
|
|
21
|
-
"Document2Outline" to NativeListIconMetadata("Document2Outline", 24f, 24f),
|
|
22
|
-
"DotHorOutline" to NativeListIconMetadata("DotHorOutline", 24f, 24f),
|
|
23
|
-
"DotVerSolid" to NativeListIconMetadata("DotVerSolid", 24f, 24f),
|
|
24
|
-
"DragOutline" to NativeListIconMetadata("DragOutline", 24f, 24f),
|
|
25
|
-
"ErrorSolid" to NativeListIconMetadata("ErrorSolid", 24f, 24f),
|
|
26
|
-
"GasSolid" to NativeListIconMetadata("GasSolid", 24f, 24f),
|
|
27
|
-
"GlobusOutline" to NativeListIconMetadata("GlobusOutline", 24f, 24f),
|
|
28
|
-
"GoogleIllus" to NativeListIconMetadata("GoogleIllus", 24f, 24f),
|
|
29
|
-
"ImageSquareWavesOutline" to NativeListIconMetadata("ImageSquareWavesOutline", 24f, 24f),
|
|
30
|
-
"InfoCircleOutline" to NativeListIconMetadata("InfoCircleOutline", 24f, 24f),
|
|
31
|
-
"LockSolid" to NativeListIconMetadata("LockSolid", 24f, 24f),
|
|
32
|
-
"MinusCircleOutline" to NativeListIconMetadata("MinusCircleOutline", 24f, 24f),
|
|
33
|
-
"MinusCircleSolid" to NativeListIconMetadata("MinusCircleSolid", 24f, 24f),
|
|
34
|
-
"PencilOutline" to NativeListIconMetadata("PencilOutline", 24f, 24f),
|
|
35
|
-
"PlusCircleOutline" to NativeListIconMetadata("PlusCircleOutline", 24f, 24f),
|
|
36
|
-
"PlusLargeOutline" to NativeListIconMetadata("PlusLargeOutline", 24f, 24f),
|
|
37
|
-
"PlusSmallOutline" to NativeListIconMetadata("PlusSmallOutline", 24f, 24f),
|
|
38
|
-
"QuestionmarkSolid" to NativeListIconMetadata("QuestionmarkSolid", 24f, 24f),
|
|
39
|
-
"RefreshCcwOutline" to NativeListIconMetadata("RefreshCcwOutline", 24f, 24f),
|
|
40
|
-
"ShieldExclamationOutline" to NativeListIconMetadata("ShieldExclamationOutline", 24f, 24f),
|
|
41
|
-
"SpeakerPromoteOutline" to NativeListIconMetadata("SpeakerPromoteOutline", 24f, 24f),
|
|
42
|
-
"StarOutline" to NativeListIconMetadata("StarOutline", 24f, 24f),
|
|
43
|
-
"StarSolid" to NativeListIconMetadata("StarSolid", 24f, 24f),
|
|
44
|
-
"SwapHorOutline" to NativeListIconMetadata("SwapHorOutline", 24f, 24f),
|
|
45
|
-
"TicketOutline" to NativeListIconMetadata("TicketOutline", 24f, 24f),
|
|
46
|
-
"WalletOutline" to NativeListIconMetadata("WalletOutline", 24f, 24f),
|
|
47
|
-
)
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// Generated by scripts/generate-icons.mjs. Coverage and legacy names only; hosts provide SVG resources.
|
|
2
|
-
import UIKit
|
|
3
|
-
|
|
4
|
-
struct NativeListIconMetadata {
|
|
5
|
-
let name: String
|
|
6
|
-
let size: CGSize
|
|
7
|
-
let original: Bool
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
enum NativeListGeneratedIcons {
|
|
11
|
-
static let icons: [String: NativeListIconMetadata] = [
|
|
12
|
-
"AccountErrorCustom": NativeListIconMetadata(name: "AccountErrorCustom", size: CGSize(width: 18, height: 18), original: true),
|
|
13
|
-
"AllNetworksSolid": NativeListIconMetadata(name: "AllNetworksSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
14
|
-
"AppleBrand": NativeListIconMetadata(name: "AppleBrand", size: CGSize(width: 16, height: 20), original: false),
|
|
15
|
-
"ArrowBottomOutline": NativeListIconMetadata(name: "ArrowBottomOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
16
|
-
"ArrowTopOutline": NativeListIconMetadata(name: "ArrowTopOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
17
|
-
"BadgeVerifiedSolid": NativeListIconMetadata(name: "BadgeRecognizedSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
18
|
-
"BotIllus": NativeListIconMetadata(name: "BotIllus", size: CGSize(width: 24, height: 24), original: true),
|
|
19
|
-
"ChartTrendingUpOutline": NativeListIconMetadata(name: "ChartTrendingUpOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
20
|
-
"CheckboxCheckedCustom": NativeListIconMetadata(name: "CheckboxCheckedCustom", size: CGSize(width: 16, height: 16), original: false),
|
|
21
|
-
"CheckboxIndeterminateCustom": NativeListIconMetadata(name: "CheckboxIndeterminateCustom", size: CGSize(width: 16, height: 16), original: false),
|
|
22
|
-
"ChevronBottomOutline": NativeListIconMetadata(name: "ChevronBottomOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
23
|
-
"ChevronGrabberVerOutline": NativeListIconMetadata(name: "ChevronGrabberVerOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
24
|
-
"ChevronRightSmallOutline": NativeListIconMetadata(name: "ChevronRightSmallOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
25
|
-
"ChevronTopOutline": NativeListIconMetadata(name: "ChevronTopOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
26
|
-
"CrossedSmallSolid": NativeListIconMetadata(name: "CrossedSmallSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
27
|
-
"CryptoCoinOutline": NativeListIconMetadata(name: "CryptoCoinOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
28
|
-
"Document2Outline": NativeListIconMetadata(name: "Document2Outline", size: CGSize(width: 24, height: 24), original: false),
|
|
29
|
-
"DotHorOutline": NativeListIconMetadata(name: "DotHorOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
30
|
-
"DotVerSolid": NativeListIconMetadata(name: "DotVerSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
31
|
-
"DragOutline": NativeListIconMetadata(name: "DragOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
32
|
-
"ErrorSolid": NativeListIconMetadata(name: "ErrorSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
33
|
-
"GasSolid": NativeListIconMetadata(name: "GasSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
34
|
-
"GlobusOutline": NativeListIconMetadata(name: "GlobusOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
35
|
-
"GoogleIllus": NativeListIconMetadata(name: "GoogleIllus", size: CGSize(width: 24, height: 24), original: true),
|
|
36
|
-
"ImageSquareWavesOutline": NativeListIconMetadata(name: "ImageSquareWavesOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
37
|
-
"InfoCircleOutline": NativeListIconMetadata(name: "InfoCircleOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
38
|
-
"LockSolid": NativeListIconMetadata(name: "LockSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
39
|
-
"MinusCircleOutline": NativeListIconMetadata(name: "MinusCircleOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
40
|
-
"MinusCircleSolid": NativeListIconMetadata(name: "MinusCircleSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
41
|
-
"PencilOutline": NativeListIconMetadata(name: "PencilOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
42
|
-
"PlusCircleOutline": NativeListIconMetadata(name: "PlusCircleOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
43
|
-
"PlusLargeOutline": NativeListIconMetadata(name: "PlusLargeOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
44
|
-
"PlusSmallOutline": NativeListIconMetadata(name: "PlusSmallOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
45
|
-
"QuestionmarkSolid": NativeListIconMetadata(name: "QuestionmarkSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
46
|
-
"RefreshCcwOutline": NativeListIconMetadata(name: "RefreshCcwOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
47
|
-
"ShieldExclamationOutline": NativeListIconMetadata(name: "ShieldExclamationOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
48
|
-
"SpeakerPromoteOutline": NativeListIconMetadata(name: "SpeakerPromoteOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
49
|
-
"StarOutline": NativeListIconMetadata(name: "StarOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
50
|
-
"StarSolid": NativeListIconMetadata(name: "StarSolid", size: CGSize(width: 24, height: 24), original: false),
|
|
51
|
-
"SwapHorOutline": NativeListIconMetadata(name: "SwapHorOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
52
|
-
"TicketOutline": NativeListIconMetadata(name: "TicketOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
53
|
-
"WalletOutline": NativeListIconMetadata(name: "WalletOutline", size: CGSize(width: 24, height: 24), original: false),
|
|
54
|
-
]
|
|
55
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import OneKeyImage
|
|
2
|
-
import UIKit
|
|
3
|
-
|
|
4
|
-
/// One request owner per glyph slot; metadata also supplies detached measurement.
|
|
5
|
-
private final class NativeListIconBinding {
|
|
6
|
-
private weak var view: UIView?
|
|
7
|
-
private let owner = NSObject()
|
|
8
|
-
private let apply: (UIImage?) -> Void
|
|
9
|
-
private var descriptor: NativeListIconMetadata?
|
|
10
|
-
private var pointSize = CGSize.zero
|
|
11
|
-
private var template = true
|
|
12
|
-
private var sizeOverride: CGSize?
|
|
13
|
-
private var currentImage: UIImage?
|
|
14
|
-
private var placeholder: UIImage?
|
|
15
|
-
private var updateDepth = 0
|
|
16
|
-
private var pendingClear = false
|
|
17
|
-
private var revision: UInt64 = 0
|
|
18
|
-
private var identity: String?
|
|
19
|
-
|
|
20
|
-
init(view: UIView, apply: @escaping (UIImage?) -> Void) { self.view = view; self.apply = apply }
|
|
21
|
-
|
|
22
|
-
func bind(_ name: String?, size: CGSize? = nil) {
|
|
23
|
-
guard let name, let metadata = nativeListIconMetadata(named: name) else {
|
|
24
|
-
clearNow(); return
|
|
25
|
-
}
|
|
26
|
-
if descriptor?.name == metadata.name, descriptor?.original == metadata.original,
|
|
27
|
-
descriptor?.size == metadata.size, sizeOverride == size {
|
|
28
|
-
pendingClear = false
|
|
29
|
-
apply(currentImage)
|
|
30
|
-
refresh(); return
|
|
31
|
-
}
|
|
32
|
-
clearNow()
|
|
33
|
-
descriptor = metadata
|
|
34
|
-
pointSize = size ?? metadata.size
|
|
35
|
-
sizeOverride = size
|
|
36
|
-
template = size != nil || !metadata.original
|
|
37
|
-
let format = UIGraphicsImageRendererFormat(); format.scale = 1
|
|
38
|
-
placeholder = UIGraphicsImageRenderer(size: pointSize, format: format).image { _ in }
|
|
39
|
-
.withRenderingMode(template ? .alwaysTemplate : .alwaysOriginal)
|
|
40
|
-
currentImage = placeholder
|
|
41
|
-
apply(currentImage)
|
|
42
|
-
refresh()
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
func clear(display: Bool = true) {
|
|
46
|
-
if display, updateDepth > 0 {
|
|
47
|
-
pendingClear = true; apply(nil); return
|
|
48
|
-
}
|
|
49
|
-
clearNow(display: display)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private func clearNow(display: Bool = true) {
|
|
53
|
-
revision &+= 1; identity = nil; descriptor = nil; currentImage = nil; placeholder = nil
|
|
54
|
-
pendingClear = false
|
|
55
|
-
OneKeyNamedSVG.shared.cancel(owner: owner)
|
|
56
|
-
if display { apply(nil) }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
func beginUpdate() { updateDepth += 1 }
|
|
60
|
-
func endUpdate() {
|
|
61
|
-
updateDepth -= 1
|
|
62
|
-
guard updateDepth == 0 else { return }
|
|
63
|
-
if pendingClear { clearNow() } else { refresh() }
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
func retint() { if descriptor != nil && !pendingClear { apply(currentImage) } }
|
|
67
|
-
|
|
68
|
-
func refresh(force: Bool = false) {
|
|
69
|
-
guard updateDepth == 0, let view, let descriptor else { return }
|
|
70
|
-
let attached = view.window != nil && !view.isHidden && !view.bounds.isEmpty
|
|
71
|
-
let screenScale = max(1, view.window?.screen.scale ?? view.traitCollection.displayScale)
|
|
72
|
-
let fit = min(view.bounds.width / pointSize.width, view.bounds.height / pointSize.height)
|
|
73
|
-
let rasterScale = ceil(screenScale * max(1, fit))
|
|
74
|
-
let next = "\(descriptor.name)|\(pointSize)|\(rasterScale)|\(screenScale)|\(attached)|\(template)"
|
|
75
|
-
guard force || next != identity else { return }
|
|
76
|
-
identity = next; revision &+= 1
|
|
77
|
-
let generation = revision
|
|
78
|
-
OneKeyNamedSVG.shared.cancel(owner: owner)
|
|
79
|
-
currentImage = placeholder
|
|
80
|
-
apply(currentImage)
|
|
81
|
-
guard attached else { return }
|
|
82
|
-
if descriptor.name == "Circle" {
|
|
83
|
-
let image = UIGraphicsImageRenderer(size: pointSize).image { _ in
|
|
84
|
-
UIColor.black.setFill(); UIBezierPath(ovalIn: CGRect(origin: .zero, size: pointSize)).fill()
|
|
85
|
-
}
|
|
86
|
-
currentImage = image.withRenderingMode(.alwaysTemplate); apply(currentImage); return
|
|
87
|
-
}
|
|
88
|
-
let sourceSize = descriptor.size
|
|
89
|
-
let sourceScale = sizeOverride == nil ? rasterScale : ceil(rasterScale * max(pointSize.width / sourceSize.width, pointSize.height / sourceSize.height))
|
|
90
|
-
let pixelWidth = ceil(sourceSize.width * sourceScale), pixelHeight = ceil(sourceSize.height * sourceScale)
|
|
91
|
-
guard pixelWidth.isFinite, pixelHeight.isFinite, pixelWidth > 0, pixelHeight > 0,
|
|
92
|
-
pixelWidth <= 4096, pixelHeight <= 4096, pixelWidth * pixelHeight <= 4_194_304 else { return }
|
|
93
|
-
OneKeyNamedSVG.shared.request(owner: owner, name: descriptor.name, color: "rgba(0,0,0,1)",
|
|
94
|
-
width: Int(pixelWidth), height: Int(pixelHeight),
|
|
95
|
-
scale: screenScale) { [weak self] image in
|
|
96
|
-
guard let self, self.revision == generation, let view = self.view,
|
|
97
|
-
view.window != nil, !view.isHidden else { return }
|
|
98
|
-
guard let cgImage = image?.cgImage else { return }
|
|
99
|
-
var result = UIImage(cgImage: cgImage, scale: sourceScale, orientation: .up)
|
|
100
|
-
if let size = self.sizeOverride {
|
|
101
|
-
let format = UIGraphicsImageRendererFormat(); format.scale = rasterScale
|
|
102
|
-
result = UIGraphicsImageRenderer(size: size, format: format).image { _ in
|
|
103
|
-
result.draw(in: CGRect(origin: .zero, size: size))
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
self.currentImage = result.withRenderingMode(self.template ? .alwaysTemplate : .alwaysOriginal)
|
|
107
|
-
self.apply(self.currentImage)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
deinit { OneKeyNamedSVG.shared.cancel(owner: owner) }
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
final class NativeListIconImageView: UIImageView {
|
|
115
|
-
private var applying = false
|
|
116
|
-
private lazy var iconBinding = NativeListIconBinding(view: self) { [weak self] image in
|
|
117
|
-
guard let self else { return }
|
|
118
|
-
self.applying = true; self.image = image; self.applying = false
|
|
119
|
-
}
|
|
120
|
-
func bindIcon(_ name: String?, size: CGSize? = nil) { iconBinding.bind(name, size: size) }
|
|
121
|
-
func beginIconUpdate() { iconBinding.beginUpdate() }
|
|
122
|
-
func endIconUpdate() { iconBinding.endUpdate() }
|
|
123
|
-
override var image: UIImage? { didSet { if !applying { iconBinding.clear(display: image == nil) } } }
|
|
124
|
-
override var isHidden: Bool { didSet { iconBinding.refresh() } }
|
|
125
|
-
override func layoutSubviews() { super.layoutSubviews(); iconBinding.refresh() }
|
|
126
|
-
override func didMoveToWindow() { super.didMoveToWindow(); iconBinding.refresh() }
|
|
127
|
-
override func tintColorDidChange() { super.tintColorDidChange(); iconBinding.retint() }
|
|
128
|
-
override func traitCollectionDidChange(_ previous: UITraitCollection?) {
|
|
129
|
-
super.traitCollectionDidChange(previous); iconBinding.refresh()
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
class NativeListIconButton: UIButton {
|
|
134
|
-
private var applying = false
|
|
135
|
-
private lazy var iconBinding = NativeListIconBinding(view: self) { [weak self] image in
|
|
136
|
-
guard let self else { return }
|
|
137
|
-
self.applying = true
|
|
138
|
-
self.setImage(image, for: .normal)
|
|
139
|
-
self.setImage(image?.withTintColor(self.tintColor, renderingMode: .alwaysOriginal), for: .disabled)
|
|
140
|
-
self.applying = false
|
|
141
|
-
}
|
|
142
|
-
func bindIcon(_ name: String?, size: CGSize? = nil) { iconBinding.bind(name, size: size) }
|
|
143
|
-
func beginIconUpdate() { iconBinding.beginUpdate() }
|
|
144
|
-
func endIconUpdate() { iconBinding.endUpdate() }
|
|
145
|
-
override func setImage(_ image: UIImage?, for state: UIControl.State) {
|
|
146
|
-
if !applying && state == .normal { iconBinding.clear(display: image == nil) }
|
|
147
|
-
super.setImage(image, for: state)
|
|
148
|
-
}
|
|
149
|
-
override var isHidden: Bool { didSet { iconBinding.refresh() } }
|
|
150
|
-
override func layoutSubviews() { super.layoutSubviews(); iconBinding.refresh() }
|
|
151
|
-
override func didMoveToWindow() { super.didMoveToWindow(); iconBinding.refresh() }
|
|
152
|
-
override func tintColorDidChange() { super.tintColorDidChange(); iconBinding.retint() }
|
|
153
|
-
override func traitCollectionDidChange(_ previous: UITraitCollection?) {
|
|
154
|
-
super.traitCollectionDidChange(previous); iconBinding.refresh()
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/// A synchronous renderer bind may clear then restore the same glyph descriptor.
|
|
159
|
-
final class NativeListIconUpdate {
|
|
160
|
-
private var images: [NativeListIconImageView] = []
|
|
161
|
-
private var buttons: [NativeListIconButton] = []
|
|
162
|
-
init(_ root: UIView) {
|
|
163
|
-
func collect(_ view: UIView) {
|
|
164
|
-
if let image = view as? NativeListIconImageView { images.append(image); image.beginIconUpdate() }
|
|
165
|
-
if let button = view as? NativeListIconButton { buttons.append(button); button.beginIconUpdate() }
|
|
166
|
-
view.subviews.forEach(collect)
|
|
167
|
-
}
|
|
168
|
-
collect(root)
|
|
169
|
-
}
|
|
170
|
-
func finish() { images.forEach { $0.endIconUpdate() }; buttons.forEach { $0.endIconUpdate() } }
|
|
171
|
-
}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import UIKit
|
|
2
|
-
import XCTest
|
|
3
|
-
import OneKeyImage
|
|
4
|
-
@testable import NativeListModule
|
|
5
|
-
|
|
6
|
-
@MainActor
|
|
7
|
-
final class NativeListSharedIconTests: XCTestCase {
|
|
8
|
-
private func field<T>(_ object: Any, _ name: String, as type: T.Type = T.self) throws -> T {
|
|
9
|
-
var mirror: Mirror? = Mirror(reflecting: object)
|
|
10
|
-
while let current = mirror {
|
|
11
|
-
if let child = current.children.first(where: { $0.label == name }) { return try XCTUnwrap(child.value as? T) }
|
|
12
|
-
mirror = current.superclassMirror
|
|
13
|
-
}
|
|
14
|
-
throw NSError(domain: "Missing field " + name, code: 1)
|
|
15
|
-
}
|
|
16
|
-
private func binding(_ button: UIButton) throws -> Any {
|
|
17
|
-
let mirror = try XCTUnwrap(Mirror(reflecting: button).superclassMirror)
|
|
18
|
-
let storage = try XCTUnwrap(mirror.children.first { $0.label?.contains("iconBinding") == true }?.value)
|
|
19
|
-
return try XCTUnwrap(Mirror(reflecting: storage).children.first?.value)
|
|
20
|
-
}
|
|
21
|
-
private func eventually(_ message: String, _ condition: () -> Bool) {
|
|
22
|
-
let end = Date().addingTimeInterval(5)
|
|
23
|
-
while !condition(), Date() < end { RunLoop.main.run(until: Date().addingTimeInterval(0.01)) }
|
|
24
|
-
XCTAssertTrue(condition(), message)
|
|
25
|
-
}
|
|
26
|
-
private func window() throws -> UIWindow {
|
|
27
|
-
guard UIApplication.perform(NSSelectorFromString("sharedApplication"))?.takeUnretainedValue() is UIApplication else {
|
|
28
|
-
throw XCTSkip("A UIApplication host is required for attached glyph acceptance")
|
|
29
|
-
}
|
|
30
|
-
let window = UIWindow(frame: UIScreen.main.bounds)
|
|
31
|
-
window.rootViewController = UIViewController()
|
|
32
|
-
window.makeKeyAndVisible()
|
|
33
|
-
return window
|
|
34
|
-
}
|
|
35
|
-
private func save(_ image: UIImage, _ name: String) throws {
|
|
36
|
-
guard let directory = ProcessInfo.processInfo.environment["ICON_EVIDENCE_DIR"] else { return }
|
|
37
|
-
try XCTUnwrap(image.pngData()).write(to: URL(fileURLWithPath: directory).appendingPathComponent(name + ".png"))
|
|
38
|
-
}
|
|
39
|
-
private func bind(_ stack: NativeListAccessoryStack, amount: String = "1", name: String = "DotVerSolid", kind: String = "icon", disabled: Bool = false) throws {
|
|
40
|
-
let descriptors: [[String: Any]] = [
|
|
41
|
-
["kind": "valuePair", "primary": amount, "secondary": "$1"],
|
|
42
|
-
["kind": kind, "name": name, "text": "Text", "buttonStyle": "tertiary", "actionKey": "menu", "disabled": disabled],
|
|
43
|
-
]
|
|
44
|
-
let item = try NativeListItem(data: ["key": "swap", "type": "identity", "title": "USDC", "height": 60, "trailing": descriptors])
|
|
45
|
-
stack.axis = .horizontal
|
|
46
|
-
stack.bind(item, descriptors: descriptors, theme: nil,
|
|
47
|
-
style: ["horizontalPadding": 20, "verticalPadding": 8, "leadingGap": 12, "trailingGap": 8],
|
|
48
|
-
checkboxState: { _, _, fallback in fallback }, fonts: NativeListFontFamilies())
|
|
49
|
-
stack.setNeedsLayout(); stack.layoutIfNeeded()
|
|
50
|
-
}
|
|
51
|
-
func testDetachedMeasurementAndRealSwapRebindPreservePendingAndReadyImage() throws {
|
|
52
|
-
let service = OneKeyNamedSVG.shared
|
|
53
|
-
let metadataLock: NSLock = try field(service, "metadataLock")
|
|
54
|
-
let stateLock: NSLock = try field(service, "lock")
|
|
55
|
-
func state(_ owner: NSObject? = nil) throws -> (Int, Int) {
|
|
56
|
-
stateLock.lock(); defer { stateLock.unlock() }
|
|
57
|
-
let pending: Any = try field(service, "pending")
|
|
58
|
-
let keys = Mirror(reflecting: pending).children.compactMap { Mirror(reflecting: $0.value).children.first?.value as? ObjectIdentifier }
|
|
59
|
-
return (try field(service, "workers"), owner.map { owner in keys.filter { $0 == ObjectIdentifier(owner) }.count } ?? keys.count)
|
|
60
|
-
}
|
|
61
|
-
metadataLock.lock()
|
|
62
|
-
var locked = true
|
|
63
|
-
defer { if locked { metadataLock.unlock() } }
|
|
64
|
-
let baseline = try state()
|
|
65
|
-
let stack = NativeListAccessoryStack(frame: CGRect(x: 10, y: 80, width: 180, height: 44))
|
|
66
|
-
try bind(stack)
|
|
67
|
-
let button = try XCTUnwrap(stack.subviews.compactMap { $0 as? NativeListAccessoryButton }.first { !$0.isHidden && $0.image(for: .normal) != nil })
|
|
68
|
-
let slot = try binding(button)
|
|
69
|
-
let owner: NSObject = try field(slot, "owner")
|
|
70
|
-
XCTAssertEqual(try state(owner).0, baseline.0)
|
|
71
|
-
XCTAssertEqual(try state(owner).1, 0)
|
|
72
|
-
let beforeSize = try XCTUnwrap(button.image(for: .normal)).size
|
|
73
|
-
let detachedSize = stack.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize)
|
|
74
|
-
XCTAssertEqual(try state(owner).0, baseline.0)
|
|
75
|
-
XCTAssertEqual(try state(owner).1, 0)
|
|
76
|
-
let window = try window(); defer { window.isHidden = true }
|
|
77
|
-
do {
|
|
78
|
-
defer { metadataLock.unlock(); locked = false }
|
|
79
|
-
window.rootViewController!.view.addSubview(stack)
|
|
80
|
-
stack.layoutIfNeeded()
|
|
81
|
-
XCTAssertGreaterThan(try state(owner).0 + state(owner).1, baseline.0)
|
|
82
|
-
let bounds = button.bounds.size
|
|
83
|
-
let revision: UInt64 = try field(slot, "revision")
|
|
84
|
-
for index in 0..<100 { try bind(stack, amount: String(index)) }
|
|
85
|
-
XCTAssertEqual(try field(slot, "revision", as: UInt64.self), revision)
|
|
86
|
-
XCTAssertEqual(button.image(for: .normal)?.size, beforeSize)
|
|
87
|
-
XCTAssertEqual(button.bounds.size, bounds)
|
|
88
|
-
XCTAssertEqual(stack.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).height, detachedSize.height)
|
|
89
|
-
}
|
|
90
|
-
eventually("Attached Swap glyph has an actual raster") { button.image(for: .normal)?.cgImage != nil && button.image(for: .normal)?.size == beforeSize && (try? self.field(slot, "currentImage", as: UIImage?.self)) != nil }
|
|
91
|
-
// A transparent measurement placeholder also has a CGImage: require painted pixels.
|
|
92
|
-
eventually("Decoded glyph is visible") { self.alphaCount(button.image(for: .normal)) > 0 }
|
|
93
|
-
let ready = try XCTUnwrap(button.image(for: .normal))
|
|
94
|
-
XCTAssertEqual(maximumAlpha(ready), 255)
|
|
95
|
-
try bind(stack, amount: "101")
|
|
96
|
-
XCTAssertTrue(button.image(for: .normal) === ready)
|
|
97
|
-
button.tintColor = .blue
|
|
98
|
-
XCTAssertTrue(button.image(for: .normal) === ready)
|
|
99
|
-
XCTAssertNotNil(button.image(for: .disabled))
|
|
100
|
-
try bind(stack, amount: "101")
|
|
101
|
-
func captureButton() -> UIImage {
|
|
102
|
-
let rect = button.convert(button.bounds, to: stack)
|
|
103
|
-
return UIGraphicsImageRenderer(size: button.bounds.size).image { context in
|
|
104
|
-
context.cgContext.translateBy(x: -rect.minX, y: -rect.minY)
|
|
105
|
-
stack.drawHierarchy(in: stack.bounds, afterScreenUpdates: true)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
try save(captureButton(), "ios-swap-menu-normal")
|
|
109
|
-
var actions = 0
|
|
110
|
-
stack.onAction = { _, _, _, _ in actions += 1 }
|
|
111
|
-
try bind(stack, amount: "101", disabled: true)
|
|
112
|
-
XCTAssertFalse(button.isEnabled); XCTAssertEqual(button.alpha, 0.4, accuracy: 0.000001)
|
|
113
|
-
XCTAssertTrue(button.image(for: .normal) === ready)
|
|
114
|
-
button.sendActions(for: .touchUpInside); XCTAssertEqual(actions, 0)
|
|
115
|
-
button.layoutIfNeeded()
|
|
116
|
-
try save(captureButton(), "ios-swap-menu-disabled")
|
|
117
|
-
try bind(stack, amount: "101")
|
|
118
|
-
try bind(stack, name: "UnknownIcon")
|
|
119
|
-
XCTAssertNil(button.image(for: .normal))
|
|
120
|
-
try bind(stack, kind: "value")
|
|
121
|
-
XCTAssertNil(button.image(for: .normal))
|
|
122
|
-
stack.removeFromSuperview()
|
|
123
|
-
RunLoop.main.run(until: Date().addingTimeInterval(0.05))
|
|
124
|
-
XCTAssertNil(button.image(for: .normal))
|
|
125
|
-
}
|
|
126
|
-
private func alphaCount(_ image: UIImage?) -> Int {
|
|
127
|
-
guard let cg = image?.cgImage else { return 0 }
|
|
128
|
-
var bytes = [UInt8](repeating: 0, count: cg.width * cg.height * 4)
|
|
129
|
-
guard let context = CGContext(data: &bytes, width: cg.width, height: cg.height, bitsPerComponent: 8,
|
|
130
|
-
bytesPerRow: cg.width * 4, space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) else { return 0 }
|
|
131
|
-
context.draw(cg, in: CGRect(x: 0, y: 0, width: cg.width, height: cg.height))
|
|
132
|
-
return stride(from: 3, to: bytes.count, by: 4).filter { bytes[$0] > 0 }.count
|
|
133
|
-
}
|
|
134
|
-
func testMainLineGlyphsPaintInTheSharedNativeSlot() throws {
|
|
135
|
-
let window = try window(); defer { window.isHidden = true }
|
|
136
|
-
let view = NativeListIconImageView(frame: CGRect(x: 10, y: 80, width: 64, height: 64))
|
|
137
|
-
window.rootViewController!.view.addSubview(view)
|
|
138
|
-
for name in ["Document2Outline", "WalletOutline", "PlusLargeOutline", "TicketOutline"] {
|
|
139
|
-
let metadata = try XCTUnwrap(nativeListIconMetadata(named: name))
|
|
140
|
-
XCTAssertEqual(metadata.name, name)
|
|
141
|
-
XCTAssertEqual(metadata.size, CGSize(width: 24, height: 24))
|
|
142
|
-
view.bindIcon(name)
|
|
143
|
-
eventually("Shared main-line glyph paints: " + name) { self.alphaCount(view.image) > 0 }
|
|
144
|
-
let image = try XCTUnwrap(view.image)
|
|
145
|
-
XCTAssertEqual(image.renderingMode, .alwaysTemplate)
|
|
146
|
-
try save(image.withTintColor(.red, renderingMode: .alwaysOriginal), "ios-main-integration-" + name)
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
private func maximumAlpha(_ image: UIImage) -> UInt8 {
|
|
150
|
-
guard let cg = image.cgImage else { return 0 }
|
|
151
|
-
var bytes = [UInt8](repeating: 0, count: cg.width * cg.height * 4)
|
|
152
|
-
guard let context = CGContext(data: &bytes, width: cg.width, height: cg.height, bitsPerComponent: 8,
|
|
153
|
-
bytesPerRow: cg.width * 4, space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) else { return 0 }
|
|
154
|
-
context.draw(cg, in: CGRect(x: 0, y: 0, width: cg.width, height: cg.height))
|
|
155
|
-
return stride(from: 3, to: bytes.count, by: 4).map { bytes[$0] }.max() ?? 0
|
|
156
|
-
}
|
|
157
|
-
func testLifecycleLegacyModesAndSizeOverride() throws {
|
|
158
|
-
let window = try window(); defer { window.isHidden = true }
|
|
159
|
-
let view = NativeListIconImageView(frame: CGRect(x: 10, y: 80, width: 64, height: 64))
|
|
160
|
-
window.rootViewController!.view.addSubview(view)
|
|
161
|
-
for name in ["AppleBrand", "BotIllus", "GoogleIllus", "AccountErrorCustom", "StarOutline", "StarSolid", "BadgeVerifiedSolid", "CheckboxCheckedCustom", "CheckboxIndeterminateCustom"] {
|
|
162
|
-
view.bindIcon(name)
|
|
163
|
-
eventually(name) { self.alphaCount(view.image) > 0 }
|
|
164
|
-
let metadata = try XCTUnwrap(nativeListIconMetadata(named: name))
|
|
165
|
-
XCTAssertEqual(view.image?.size, metadata.size)
|
|
166
|
-
if !metadata.original { XCTAssertEqual(maximumAlpha(try XCTUnwrap(view.image)), 255) }
|
|
167
|
-
XCTAssertEqual(view.image?.renderingMode, metadata.original ? .alwaysOriginal : .alwaysTemplate)
|
|
168
|
-
let image = try XCTUnwrap(view.image)
|
|
169
|
-
try save(metadata.original ? image : image.withTintColor(.red, renderingMode: .alwaysOriginal), "ios-new-" + name)
|
|
170
|
-
}
|
|
171
|
-
view.bindIcon("AppleBrand", size: CGSize(width: 28, height: 20))
|
|
172
|
-
eventually("Non-square source stretches to legacy explicit size") { self.alphaCount(view.image) > 0 }
|
|
173
|
-
XCTAssertEqual(view.image?.size, CGSize(width: 28, height: 20))
|
|
174
|
-
XCTAssertEqual(view.image?.renderingMode, .alwaysTemplate)
|
|
175
|
-
try save(try XCTUnwrap(view.image).withTintColor(.red, renderingMode: .alwaysOriginal), "ios-new-AppleBrand-override")
|
|
176
|
-
view.bindIcon("DotVerSolid")
|
|
177
|
-
view.removeFromSuperview()
|
|
178
|
-
RunLoop.main.run(until: Date().addingTimeInterval(0.1))
|
|
179
|
-
XCTAssertEqual(alphaCount(view.image), 0)
|
|
180
|
-
window.rootViewController!.view.addSubview(view)
|
|
181
|
-
eventually("Same glyph redraws after detached completion") { self.alphaCount(view.image) > 0 }
|
|
182
|
-
view.bindIcon("UnknownIcon"); XCTAssertNil(view.image)
|
|
183
|
-
let ordinary = UIGraphicsImageRenderer(size: CGSize(width: 8, height: 8)).image { c in UIColor.green.setFill(); c.fill(CGRect(x: 0, y: 0, width: 8, height: 8)) }
|
|
184
|
-
view.image = ordinary
|
|
185
|
-
XCTAssertTrue(view.image === ordinary)
|
|
186
|
-
}
|
|
187
|
-
func testLegacyCompiledAssetRasterComparison() throws {
|
|
188
|
-
guard let directory = ProcessInfo.processInfo.environment["NATIVE_LIST_LEGACY_BUNDLE"], let bundle = Bundle(path: directory) else {
|
|
189
|
-
throw XCTSkip("An archived pre-migration resource bundle is required for raster comparison")
|
|
190
|
-
}
|
|
191
|
-
let window = try window(); defer { window.isHidden = true }
|
|
192
|
-
let view = NativeListIconImageView(frame: CGRect(x: 0, y: 80, width: 96, height: 96))
|
|
193
|
-
window.rootViewController!.view.addSubview(view)
|
|
194
|
-
let names = [
|
|
195
|
-
"AppleBrand": "onekey_selector_apple_brand", "BotIllus": "onekey_selector_bot_illus",
|
|
196
|
-
"GoogleIllus": "onekey_selector_google_illus", "AccountErrorCustom": "onekey_selector_account_error_custom",
|
|
197
|
-
"BadgeVerifiedSolid": "onekey_badge_verified_solid", "StarOutline": "onekey_star", "StarSolid": "onekey_star_solid",
|
|
198
|
-
"CheckboxCheckedCustom": "onekey_checkbox_checked", "CheckboxIndeterminateCustom": "onekey_checkbox_indeterminate",
|
|
199
|
-
]
|
|
200
|
-
func raster(_ image: UIImage) -> UIImage {
|
|
201
|
-
let format = UIGraphicsImageRendererFormat(); format.scale = 1
|
|
202
|
-
return UIGraphicsImageRenderer(size: CGSize(width: 96, height: 96), format: format).image { _ in
|
|
203
|
-
image.draw(in: CGRect(x: 0, y: 0, width: 96, height: 96))
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
for name in names.keys.sorted() {
|
|
207
|
-
let metadata = try XCTUnwrap(nativeListIconMetadata(named: name))
|
|
208
|
-
let old = try XCTUnwrap(UIImage(named: names[name]!, in: bundle, compatibleWith: nil))
|
|
209
|
-
view.bindIcon(name)
|
|
210
|
-
eventually("Shared raster for legacy comparison " + name) { self.alphaCount(view.image) > 0 }
|
|
211
|
-
let next = try XCTUnwrap(view.image)
|
|
212
|
-
XCTAssertEqual(next.size, old.size)
|
|
213
|
-
let before = raster(metadata.original ? old : old.withTintColor(.red, renderingMode: .alwaysOriginal))
|
|
214
|
-
let after = raster(metadata.original ? next : next.withTintColor(.red, renderingMode: .alwaysOriginal))
|
|
215
|
-
XCTAssertGreaterThan(alphaCount(before), 0); XCTAssertGreaterThan(alphaCount(after), 0)
|
|
216
|
-
if name == "AccountErrorCustom" {
|
|
217
|
-
// The source eye center is inside its 0.447-opacity fill, away from raster edges.
|
|
218
|
-
for image in [before, after] {
|
|
219
|
-
let cg = try XCTUnwrap(image.cgImage)
|
|
220
|
-
var bytes = [UInt8](repeating: 0, count: 96 * 96 * 4)
|
|
221
|
-
let context = try XCTUnwrap(CGContext(data: &bytes, width: 96, height: 96, bitsPerComponent: 8,
|
|
222
|
-
bytesPerRow: 96 * 4, space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue))
|
|
223
|
-
context.draw(cg, in: CGRect(x: 0, y: 0, width: 96, height: 96))
|
|
224
|
-
for (x,y) in [(6,48),(48,6),(48,91),(91,64),(67,61)] {
|
|
225
|
-
let index = (y * 96 + x) * 4
|
|
226
|
-
XCTAssertEqual(Array(bytes[index..<(index+3)]), [0,0,0])
|
|
227
|
-
XCTAssertEqual(bytes[index+3], 114)
|
|
228
|
-
}
|
|
229
|
-
for (x,y) in [(48,48),(15,48)] { XCTAssertEqual(bytes[(y * 96 + x) * 4 + 3], 0) }
|
|
230
|
-
}
|
|
231
|
-
} else { XCTAssertEqual(maximumAlpha(after), maximumAlpha(before)) }
|
|
232
|
-
try save(before, "ios-before-" + name); try save(after, "ios-after-" + name)
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// Generated by scripts/generate-icons.mjs. Coverage and legacy names only; hosts provide SVG resources.
|
|
4
|
-
export const nativeListGeneratedIcons = {
|
|
5
|
-
AccountErrorCustom: 'AccountErrorCustom',
|
|
6
|
-
AllNetworksSolid: 'AllNetworksSolid',
|
|
7
|
-
AppleBrand: 'AppleBrand',
|
|
8
|
-
BadgeVerifiedSolid: 'BadgeRecognizedSolid',
|
|
9
|
-
BotIllus: 'BotIllus',
|
|
10
|
-
CheckboxCheckedCustom: 'CheckboxCheckedCustom',
|
|
11
|
-
CheckboxIndeterminateCustom: 'CheckboxIndeterminateCustom',
|
|
12
|
-
ChevronRightSmallOutline: 'ChevronRightSmallOutline',
|
|
13
|
-
Circle: 'Circle',
|
|
14
|
-
CrossedSmallSolid: 'CrossedSmallSolid',
|
|
15
|
-
CryptoCoinOutline: 'CryptoCoinOutline',
|
|
16
|
-
Document2Outline: 'Document2Outline',
|
|
17
|
-
DotHorOutline: 'DotHorOutline',
|
|
18
|
-
DotVerSolid: 'DotVerSolid',
|
|
19
|
-
DragOutline: 'DragOutline',
|
|
20
|
-
GasSolid: 'GasSolid',
|
|
21
|
-
GlobusOutline: 'GlobusOutline',
|
|
22
|
-
GoogleIllus: 'GoogleIllus',
|
|
23
|
-
LockSolid: 'LockSolid',
|
|
24
|
-
PencilOutline: 'PencilOutline',
|
|
25
|
-
PlusLargeOutline: 'PlusLargeOutline',
|
|
26
|
-
PlusSmallOutline: 'PlusSmallOutline',
|
|
27
|
-
RefreshCcwOutline: 'RefreshCcwOutline',
|
|
28
|
-
TicketOutline: 'TicketOutline',
|
|
29
|
-
WalletOutline: 'WalletOutline'
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=NativeListGeneratedIcons.js.map
|