Files
iOS/Tools/icons.stencil
Zac West a2491d632d Minor fixes for open page widget (#1867)
## Summary
- Fixes e.g. HACS (which is `hacs:hacs`) icons showing the A/B icon. We now fall back to the outline cog.
- Hide panels without the "show in sidebar" option. We get them in the response, but e.g. the title is incorrect.
- Changes sort order in the automatic version to more closely align with the frontend.
- Fixes a case where chosen panels in the past would fail to be updated due to being at the tail end of the array in the API response, due to truncating to widget size _before_ updating.

## Screenshots
![image](https://user-images.githubusercontent.com/74188/135203919-d2951c9a-0bfe-4eb4-8285-a74f9c546882.png)
2021-09-29 04:49:43 +00:00

68 lines
2.4 KiB
Plaintext

// swiftlint:disable all
// swiftformat:disable all
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
// NOTE: many type declarations are extremely verbose here to improve compile times
import Foundation
{% macro caseName name %}{{name|swiftIdentifier|snakeToCamelCase|lowerFirstWord}}Icon{% endmacro %}
{% macro unicodeValue codepoint %}"{{ "\u{" }}{{ codepoint }}{{ "}" }}"{% endmacro %}
{% macro valueName name %}"{{name|swiftIdentifier|lowercase}}"{% endmacro %}
{% if files %}
{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
{% for file in files %}
{% set icons file.document.data %}
{% set typeName %}{{param.typeName|default:file.name}}{% endset %}
{{ accessModifier }} final class {{ typeName }}: CaseIterable, Hashable, Equatable, CustomStringConvertible, IconDrawable {
{{ accessModifier }} static let familyName: String = "{{ typeName }}"
{{ accessModifier }} static let count: Int = {{ icons.count }}
{{ accessModifier }} let name: String
{{ accessModifier }} let unicode: String
{{ accessModifier }} var description: String {
"<MaterialDesignIcons: \(name)>"
}
public convenience init(named iconName: String) {
self.init(named: iconName, fallback: Self.allCases.first!)
}
public convenience init(named iconName: String, fallback: MaterialDesignIcons) {
let existing: {{ typeName }}
if let found = Self.allCases.first(where: { $0.name == iconName.lowercased() }) {
existing = found
} else {
existing = fallback
}
self.init(name: existing.name, unicode: existing.unicode)
}
private init(name: String, unicode: String) {
self.name = name
self.unicode = unicode
}
{{ accessModifier }} static func == (lhs: {{ typeName }}, rhs: {{ typeName }}) -> Bool {
lhs.unicode == rhs.unicode
}
{{ accessModifier }} func hash(into hasher: inout Hasher) {
hasher.combine(unicode)
}
{% for icon in icons %}
{{ accessModifier }} static let {% call caseName icon.name %} = {{ typeName }}(name: {% call valueName icon.name %}, unicode: {% call unicodeValue icon.codepoint %})
{% endfor %}
{{ accessModifier }} static let allCases: [{{ typeName }}] = [
{% for icon in icons %}
{{ typeName }}.{% call caseName icon.name %},
{% endfor %}
]
}
{% endfor %}
{% endif %}