Skip to content

Commit

Permalink
Support iconify icons (#724)
Browse files Browse the repository at this point in the history
* Support iconify icons

Closes #716

Signed-off-by: Cody Cutrer <[email protected]>

* Update Kingfisher to resolve build issue

Signed-off-by: Cody Cutrer <[email protected]>

---------

Signed-off-by: Cody Cutrer <[email protected]>
  • Loading branch information
ccutrer authored Aug 19, 2023
1 parent 2e7f561 commit a9fd87b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- Implement iconify icons
- Update Kingfisher to fix build issue

## [Version 2.4.58, Build 1580410536] - 2023-05-31Z

- Implement forceAsItem support for Charts in Sitemaps
Expand Down
23 changes: 22 additions & 1 deletion OpenHABCore/Sources/OpenHABCore/Util/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public extension Endpoint {
}

static func icon(rootUrl: String, version: Int, icon: String?, state: String, iconType: IconType) -> Endpoint {
guard let icon, !icon.isEmpty else {
guard var icon, !icon.isEmpty else {
return Endpoint(baseURL: "", path: "", queryItems: [])
}

Expand All @@ -157,6 +157,27 @@ public extension Endpoint {
var queryItems = [
URLQueryItem(name: "state", value: state)
]
if version >= 4 {
let components = icon.components(separatedBy: ":")
var source = ""
var set = ""
if components.count == 3 {
source = components[0]
set = components[1]
icon = components[2]
} else if components.count == 2 {
source = components[0]
set = "classic"
icon = components[2]
}
if source == "if" || source == "iconify" {
return Endpoint(
baseURL: "https://api.iconify.design/",
path: "/\(set)/\(icon).svg",
queryItems: [URLQueryItem(name: "height", value: "64")]
)
}
}
if version >= 3 {
queryItems.append(contentsOf: [
URLQueryItem(name: "format", value: (iconType == .png) ? "PNG" : "SVG"),
Expand Down
4 changes: 2 additions & 2 deletions openHAB.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@
"repositoryURL": "https://github.com/onevcat/Kingfisher.git",
"state": {
"branch": null,
"revision": "318e319998bf555c3e914d5c3adb6da05af86a32",
"version": "7.1.1"
"revision": "c1f60c63f356d364f4284ba82961acbe7de79bcc",
"version": "7.8.1"
}
},
{
Expand Down

0 comments on commit a9fd87b

Please sign in to comment.