mirror of
https://github.com/home-assistant/iOS.git
synced 2026-06-16 13:26:27 -05:00
## 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 
68 lines
2.4 KiB
Plaintext
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 %}
|