diff --git a/.github/scripts/conventions.sh b/.github/scripts/conventions.sh index b32eb63..1a0c592 100755 --- a/.github/scripts/conventions.sh +++ b/.github/scripts/conventions.sh @@ -399,7 +399,7 @@ check_literals() { } # 1. Icons: `case a = "x"`, `case a` (raw value is the name), `case a, b = "y"`, -# read only directly inside an enum whose declaration (up to its "{", on one line +# a name in backticks (`case `public` = "x"`), read only directly inside an enum whose declaration (up to its "{", on one line # or several) names DashIconAsset. Lines of any other shape (`case let …`, # associated values) are not icons. icon_values=$work/icon-values @@ -407,15 +407,15 @@ awk -v f="$icons" ' function cases(text, ln, item, one, value) { sub(/^[[:space:]]+/, "", text) sub(/[[:space:]]*\}[[:space:]]*$/, "", text) - if (text !~ /^case[[:space:]]+[A-Za-z_]/) return + if (text !~ /^case[[:space:]]+`?[A-Za-z_]/) return sub(/^case[[:space:]]+/, "", text) - item = "[A-Za-z_][A-Za-z0-9_]*([[:space:]]*=[[:space:]]*\"[^\"]*\")?" + item = "(`[A-Za-z_][A-Za-z0-9_]*`|[A-Za-z_][A-Za-z0-9_]*)([[:space:]]*=[[:space:]]*\"[^\"]*\")?" if (text !~ ("^" item "([[:space:]]*,[[:space:]]*" item ")*[[:space:]]*$")) return while (match(text, item)) { one = substr(text, RSTART, RLENGTH) text = substr(text, RSTART + RLENGTH) if (match(one, /"[^"]*"/)) value = substr(one, RSTART + 1, RLENGTH - 2) - else value = one + else { value = one; gsub(/`/, "", value) } print value "\t" f "\t" ln } } diff --git a/.github/scripts/tests/conventions-test.sh b/.github/scripts/tests/conventions-test.sh index bfad3cc..8b00ba8 100755 --- a/.github/scripts/tests/conventions-test.sh +++ b/.github/scripts/tests/conventions-test.sh @@ -83,6 +83,7 @@ fresh; printf '%s\n' 'enum FixtureIcon: String, CaseIterable, DashIconAsset {' \ ' case ghost = "no-such-icon"' \ ' case noSuchBare' \ ' case listA = "nope-a", listB' \ + " case \`default\` = \"no-such-ticked\", \`bareTicked\`" \ " case dup = \"${img}\"" \ ' func f() { switch self { case let x where x == .ghost: break; default: break } }' \ '}' >> "$work/tree/$src/Foundation/Icon_DashUI.swift" @@ -91,6 +92,8 @@ expect "enum cases without assets" fail \ 'no imageset named "noSuchBare"' \ 'no imageset named "nope-a"' \ 'no imageset named "listB"' \ + 'no imageset named "no-such-ticked"' \ + 'no imageset named "bareTicked"' \ "\"${img}\" is declared more than once" fresh; mkdir "$work/tree/$catalog/Fixture & Folder"; cp -R "$(first_set imageset)" "$work/tree/$catalog/Fixture & Folder/" diff --git a/SnapshotTests/Tests/DashUIKitSnapshotTests/SystemMessageViewSnapshotTests.swift b/SnapshotTests/Tests/DashUIKitSnapshotTests/SystemMessageViewSnapshotTests.swift index 0e42ad6..61e78a7 100644 --- a/SnapshotTests/Tests/DashUIKitSnapshotTests/SystemMessageViewSnapshotTests.swift +++ b/SnapshotTests/Tests/DashUIKitSnapshotTests/SystemMessageViewSnapshotTests.swift @@ -77,5 +77,15 @@ final class SystemMessageViewSnapshotTests: XCTestCase { } try assertComponentSnapshots(of: view, named: "link-action") } + + /// The coloured public icon (no template tint), on the default surface. + func testPublicIcon() throws { + let view = SystemMessageView( + title: "This transaction will be public", + subtitle: "The amount and the destination address will be visible on the blockchain.", + icon: DashIcon.SystemMessage.public.source + ) + try assertComponentSnapshots(of: view, named: "public-icon") + } } #endif diff --git a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/SystemMessageViewSnapshotTests/testPublicIcon.public-icon-dark.png b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/SystemMessageViewSnapshotTests/testPublicIcon.public-icon-dark.png new file mode 100644 index 0000000..76513bb Binary files /dev/null and b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/SystemMessageViewSnapshotTests/testPublicIcon.public-icon-dark.png differ diff --git a/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/SystemMessageViewSnapshotTests/testPublicIcon.public-icon-light.png b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/SystemMessageViewSnapshotTests/testPublicIcon.public-icon-light.png new file mode 100644 index 0000000..c99d6e3 Binary files /dev/null and b/SnapshotTests/Tests/DashUIKitSnapshotTests/__Snapshots__/SystemMessageViewSnapshotTests/testPublicIcon.public-icon-light.png differ diff --git a/Sources/DashUIKit/Components/SystemMessageView.swift b/Sources/DashUIKit/Components/SystemMessageView.swift index f732d6b..0495085 100644 --- a/Sources/DashUIKit/Components/SystemMessageView.swift +++ b/Sources/DashUIKit/Components/SystemMessageView.swift @@ -167,4 +167,13 @@ public struct SystemMessageView: View { .padding() } +#Preview("Public icon") { + SystemMessageView( + title: "This transaction will be public", + subtitle: "The amount and the destination address will be visible on the blockchain.", + icon: DashIcon.SystemMessage.public.source + ) + .padding() +} + #endif // DEBUG diff --git a/Sources/DashUIKit/Foundation/Icon_DashUI.swift b/Sources/DashUIKit/Foundation/Icon_DashUI.swift index 4464c5a..79ccfbe 100644 --- a/Sources/DashUIKit/Foundation/Icon_DashUI.swift +++ b/Sources/DashUIKit/Foundation/Icon_DashUI.swift @@ -234,6 +234,7 @@ public enum DashIcon { /// `System message` public enum SystemMessage: String, CaseIterable, DashIconAsset { case infoRectSmall = "system-message-info-rect-small" + case `public` = "system-message-public" case shieldSmall = "system-message-shield-small" case timerSmall = "system-message-timer-small" case unmixedFunds = "system-message-unmixed-funds" diff --git a/Sources/DashUIKit/Resources/Media.xcassets/Icons & Illustrations/System message/system-message-public.imageset/Contents.json b/Sources/DashUIKit/Resources/Media.xcassets/Icons & Illustrations/System message/system-message-public.imageset/Contents.json new file mode 100644 index 0000000..3950fe0 --- /dev/null +++ b/Sources/DashUIKit/Resources/Media.xcassets/Icons & Illustrations/System message/system-message-public.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "system-message-public.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "original" + } +} diff --git a/Sources/DashUIKit/Resources/Media.xcassets/Icons & Illustrations/System message/system-message-public.imageset/system-message-public.svg b/Sources/DashUIKit/Resources/Media.xcassets/Icons & Illustrations/System message/system-message-public.imageset/system-message-public.svg new file mode 100644 index 0000000..eec355b --- /dev/null +++ b/Sources/DashUIKit/Resources/Media.xcassets/Icons & Illustrations/System message/system-message-public.imageset/system-message-public.svg @@ -0,0 +1,4 @@ + + + + diff --git a/docs/foundation.md b/docs/foundation.md index 951b43f..2136ab2 100644 --- a/docs/foundation.md +++ b/docs/foundation.md @@ -123,7 +123,11 @@ icons, text-field icons (`text-field-qr`, `text-field-clear`), menu icons (`feature-shield`, `feature-timer`, `feature-identity`, `feature-platform`, each with a `-purple` variant where one exists), segmented-control arrows (`segmented-control-receive/transfer/send`, each with a grey `-disabled` twin for -the unselected segment), the vote thumb (`voting-thumb-up`), the list filter glyph (`filter-s`), and illustrations +the unselected segment), system-message icons (`system-message-info-rect-small`, +`system-message-public`, `system-message-shield-small`, `system-message-timer-small`, +`system-message-unmixed-funds`, `system-message-username-change`, +`system-message-warning-triangle`), the vote thumb (`voting-thumb-up`), the list +filter glyph (`filter-s`), and illustrations (`illustration-dash-dex`, `illustration-xmark`, `checkmark`, `crowdnode.warning`).