-
Notifications
You must be signed in to change notification settings - Fork 2
/
SwiftGen-xcassets.stencil
41 lines (38 loc) · 1.44 KB
/
SwiftGen-xcassets.stencil
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// swift-format-ignore-file
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
{% if catalogs %}
import SwiftUI
{% macro casesBlock assets %}
{% for asset in assets %}
{% if asset.items and asset.isNamespaced == "true" %}
public enum {{asset.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
{% filter indent:2 %}{% call casesBlock asset.items %}{% endfilter %}
}
{% elif asset.items %}
{% call casesBlock asset.items %}
{% elif asset.type == "color" %}
public static let {{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = Color("{{asset.value}}", bundle: Bundle.swiftUIPreviewsCompatibleModule)
{% elif asset.type == "image" %}
public static let {{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = Image("{{asset.value}}", bundle: Bundle.swiftUIPreviewsCompatibleModule)
{% endif %}
{% endfor %}
{% endmacro %}
/// Cases to reference for safely initializing colors, like so: `Clr.Fill.primary`
public enum Clr {
{% for catalog in catalogs %}
{% if catalog.name == "Colors" %}
{% call casesBlock catalog.assets %}
{% endif %}
{% endfor %}
}
/// Cases to reference for safely initializing images, like so: `Img.Onboarding.header`
public enum Img {
{% for catalog in catalogs %}
{% if catalog.name == "Images" %}
{% call casesBlock catalog.assets %}
{% endif %}
{% endfor %}
}
{% else %}
// No assets found
{% endif %}