diff --git a/OpenHABCore/Sources/OpenHABCore/Model/OpenHABWidget.swift b/OpenHABCore/Sources/OpenHABCore/Model/OpenHABWidget.swift index 86971fb8e..a7fcaaa71 100644 --- a/OpenHABCore/Sources/OpenHABCore/Model/OpenHABWidget.swift +++ b/OpenHABCore/Sources/OpenHABCore/Model/OpenHABWidget.swift @@ -310,7 +310,7 @@ public extension OpenHABWidget { let refresh: Int? let height: Double? let isLeaf: Bool? - let iconColor: String? + let iconcolor: String? let labelcolor: String? let valuecolor: String? let service: String? @@ -333,7 +333,7 @@ public extension OpenHABWidget { extension OpenHABWidget.CodingData { var openHABWidget: OpenHABWidget { let mappedWidgets = widgets.map(\.openHABWidget) - return OpenHABWidget(widgetId: widgetId, label: label, icon: icon, type: type, url: url, period: period, minValue: minValue, maxValue: maxValue, step: step, refresh: refresh, height: height, isLeaf: isLeaf, iconColor: iconColor, labelColor: labelcolor, valueColor: valuecolor, service: service, state: state, text: text, legend: legend, encoding: encoding, item: item?.openHABItem, linkedPage: linkedPage, mappings: mappings, widgets: mappedWidgets, visibility: visibility, switchSupport: switchSupport, forceAsItem: forceAsItem) + return OpenHABWidget(widgetId: widgetId, label: label, icon: icon, type: type, url: url, period: period, minValue: minValue, maxValue: maxValue, step: step, refresh: refresh, height: height, isLeaf: isLeaf, iconColor: iconcolor, labelColor: labelcolor, valueColor: valuecolor, service: service, state: state, text: text, legend: legend, encoding: encoding, item: item?.openHABItem, linkedPage: linkedPage, mappings: mappings, widgets: mappedWidgets, visibility: visibility, switchSupport: switchSupport, forceAsItem: forceAsItem) } } diff --git a/OpenHABCore/Sources/OpenHABCore/Util/Endpoint.swift b/OpenHABCore/Sources/OpenHABCore/Util/Endpoint.swift index b00ebedb6..b2197efd1 100644 --- a/OpenHABCore/Sources/OpenHABCore/Util/Endpoint.swift +++ b/OpenHABCore/Sources/OpenHABCore/Util/Endpoint.swift @@ -147,7 +147,7 @@ public extension Endpoint { return endpoint } - static func icon(rootUrl: String, version: Int, icon: String?, state: String, iconType: IconType) -> Endpoint { + static func icon(rootUrl: String, version: Int, icon: String?, state: String, iconType: IconType, iconColor: String) -> Endpoint { guard var icon, !icon.isEmpty else { return Endpoint(baseURL: "", path: "", queryItems: []) } @@ -171,10 +171,14 @@ public extension Endpoint { icon = components[2] } if source == "if" || source == "iconify" { + queryItems = [URLQueryItem(name: "height", value: "64")] + if !iconColor.isEmpty { + queryItems.append(URLQueryItem(name: "color", value: iconColor)) + } return Endpoint( baseURL: "https://api.iconify.design/", path: "/\(set)/\(icon).svg", - queryItems: [URLQueryItem(name: "height", value: "64")] + queryItems: queryItems ) } } diff --git a/OpenHABCore/Tests/OpenHABCoreTests/OpenHABCoreGeneralTests.swift b/OpenHABCore/Tests/OpenHABCoreTests/OpenHABCoreGeneralTests.swift index 5b80d3f04..71a4c70e0 100644 --- a/OpenHABCore/Tests/OpenHABCoreTests/OpenHABCoreGeneralTests.swift +++ b/OpenHABCore/Tests/OpenHABCoreTests/OpenHABCoreGeneralTests.swift @@ -22,7 +22,8 @@ final class OpenHABCoreGeneralTests: XCTestCase { version: 2, icon: "switch", state: "OFF", - iconType: .svg + iconType: .svg, + iconColor: "" ).url XCTAssertEqual(urlc, URL(string: "http://192.169.2.1/icon/switch?state=OFF&format=SVG"), "Check endpoint creation") } diff --git a/openHAB.xcodeproj/project.pbxproj b/openHAB.xcodeproj/project.pbxproj index fefcaaaad..db235242a 100644 --- a/openHAB.xcodeproj/project.pbxproj +++ b/openHAB.xcodeproj/project.pbxproj @@ -1517,7 +1517,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1580410537; + CURRENT_PROJECT_VERSION = 1580410538; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = PBAPXHRAM9; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -1531,7 +1531,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.4.59; + MARKETING_VERSION = 2.4.60; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = es.spaphone.openhab.openHABIntents; @@ -1560,7 +1560,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 1580410537; + CURRENT_PROJECT_VERSION = 1580410538; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = PBAPXHRAM9; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -1573,7 +1573,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.4.59; + MARKETING_VERSION = 2.4.60; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = es.spaphone.openhab.openHABIntents; @@ -1620,6 +1620,7 @@ CURRENT_PROJECT_VERSION = 1580410532; CURRENT_PROJECT_VERSION = 1580410536; CURRENT_PROJECT_VERSION = 1580410537; + CURRENT_PROJECT_VERSION = 1580410538; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = PBAPXHRAM9; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -1650,6 +1651,7 @@ MARKETING_VERSION = 2.4.57; MARKETING_VERSION = 2.4.58; MARKETING_VERSION = 2.4.59; + MARKETING_VERSION = 2.4.60; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = es.spaphone.openHABUITests; @@ -1700,6 +1702,7 @@ CURRENT_PROJECT_VERSION = 1580410532; CURRENT_PROJECT_VERSION = 1580410536; CURRENT_PROJECT_VERSION = 1580410537; + CURRENT_PROJECT_VERSION = 1580410538; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = PBAPXHRAM9; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -1730,6 +1733,7 @@ MARKETING_VERSION = 2.4.57; MARKETING_VERSION = 2.4.58; MARKETING_VERSION = 2.4.59; + MARKETING_VERSION = 2.4.60; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = es.spaphone.openHABUITests; @@ -1996,7 +2000,7 @@ CURRENT_PROJECT_VERSION = 1580410446; CURRENT_PROJECT_VERSION = 1580410455; "CODE_SIGN_STYLE[sdk=*]" = Automatic; - CURRENT_PROJECT_VERSION = 1580410537; + CURRENT_PROJECT_VERSION = 1580410538; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = PBAPXHRAM9; GCC_C_LANGUAGE_STANDARD = "compiler-default"; @@ -2009,7 +2013,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.4.59; + MARKETING_VERSION = 2.4.60; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = es.spaphone.openhab.watchkitapp; @@ -2063,6 +2067,7 @@ CURRENT_PROJECT_VERSION = 1580410532; CURRENT_PROJECT_VERSION = 1580410536; CURRENT_PROJECT_VERSION = 1580410537; + CURRENT_PROJECT_VERSION = 1580410538; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = PBAPXHRAM9; GCC_C_LANGUAGE_STANDARD = "compiler-default"; @@ -2075,7 +2080,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2.4.59; + MARKETING_VERSION = 2.4.60; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = es.spaphone.openhab.watchkitapp; @@ -2269,6 +2274,7 @@ CURRENT_PROJECT_VERSION = 1580410532; CURRENT_PROJECT_VERSION = 1580410536; CURRENT_PROJECT_VERSION = 1580410537; + CURRENT_PROJECT_VERSION = 1580410538; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = PBAPXHRAM9; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -2299,6 +2305,7 @@ MARKETING_VERSION = 2.4.57; MARKETING_VERSION = 2.4.58; MARKETING_VERSION = 2.4.59; + MARKETING_VERSION = 2.4.60; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.reg-labs.openHABTestsSwift"; @@ -2350,6 +2357,7 @@ CURRENT_PROJECT_VERSION = 1580410532; CURRENT_PROJECT_VERSION = 1580410536; CURRENT_PROJECT_VERSION = 1580410537; + CURRENT_PROJECT_VERSION = 1580410538; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = PBAPXHRAM9; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -2380,6 +2388,7 @@ MARKETING_VERSION = 2.4.57; MARKETING_VERSION = 2.4.58; MARKETING_VERSION = 2.4.59; + MARKETING_VERSION = 2.4.60; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.reg-labs.openHABTestsSwift"; @@ -2542,6 +2551,7 @@ CURRENT_PROJECT_VERSION = 1580410532; CURRENT_PROJECT_VERSION = 1580410536; CURRENT_PROJECT_VERSION = 1580410537; + CURRENT_PROJECT_VERSION = 1580410538; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = PBAPXHRAM9; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -2577,6 +2587,7 @@ MARKETING_VERSION = 2.4.57; MARKETING_VERSION = 2.4.58; MARKETING_VERSION = 2.4.59; + MARKETING_VERSION = 2.4.60; OTHER_SWIFT_FLAGS = "$(inherited) -DDEBUG -Xfrontend -warn-long-expression-type-checking=200 -Xfrontend -warn-long-function-bodies=200"; PRODUCT_BUNDLE_IDENTIFIER = es.spaphone.openhab; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2610,7 +2621,7 @@ CODE_SIGN_IDENTITY = "Apple Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 1580410537; + CURRENT_PROJECT_VERSION = 1580410538; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = PBAPXHRAM9; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -2646,6 +2657,7 @@ MARKETING_VERSION = 2.4.57; MARKETING_VERSION = 2.4.58; MARKETING_VERSION = 2.4.59; + MARKETING_VERSION = 2.4.60; PRODUCT_BUNDLE_IDENTIFIER = es.spaphone.openhab; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; diff --git a/openHAB/OpenHABNotificationsViewController.swift b/openHAB/OpenHABNotificationsViewController.swift index 1f604b87c..df9274fd8 100644 --- a/openHAB/OpenHABNotificationsViewController.swift +++ b/openHAB/OpenHABNotificationsViewController.swift @@ -100,7 +100,8 @@ class OpenHABNotificationsViewController: UITableViewController { version: appData!.openHABVersion, icon: notification.icon, state: "", - iconType: .png + iconType: .png, + iconColor: "" ).url { cell?.imageView?.kf.setImage( with: iconUrl, diff --git a/openHAB/OpenHABSitemapViewController.swift b/openHAB/OpenHABSitemapViewController.swift index 019f6b272..76288e47c 100644 --- a/openHAB/OpenHABSitemapViewController.swift +++ b/openHAB/OpenHABSitemapViewController.swift @@ -679,6 +679,10 @@ extension OpenHABSitemapViewController: UITableViewDelegate, UITableViewDataSour cell = tableView.dequeueReusableCell(for: indexPath) as GenericUITableViewCell } + var iconColor = widget?.iconColor + if (iconColor == nil || iconColor!.isEmpty), traitCollection.userInterfaceStyle == .dark { + iconColor = "white" + } // No icon is needed for image, video, frame and web widgets if widget?.icon != nil, !((cell is NewImageUITableViewCell) || (cell is VideoUITableViewCell) || (cell is FrameUITableViewCell) || (cell is WebUITableViewCell)) { if let urlc = Endpoint.icon( @@ -686,7 +690,8 @@ extension OpenHABSitemapViewController: UITableViewDelegate, UITableViewDataSour version: appData?.openHABVersion ?? 2, icon: widget?.icon, state: widget?.iconState() ?? "", - iconType: iconType + iconType: iconType, + iconColor: iconColor! ).url { var imageRequest = URLRequest(url: urlc) imageRequest.timeoutInterval = 10.0 diff --git a/openHABWatch Extension/Views/Rows/ImageRow.swift b/openHABWatch Extension/Views/Rows/ImageRow.swift index 333902e2f..f6ecef106 100644 --- a/openHABWatch Extension/Views/Rows/ImageRow.swift +++ b/openHABWatch Extension/Views/Rows/ImageRow.swift @@ -43,7 +43,8 @@ struct ImageRow_Previews: PreviewProvider { version: 2, icon: "Switch", state: "ON", - iconType: .png + iconType: .png, + iconColor: "" ).url // let widget = UserData().widgets[8] return ImageRow(URL: iconURL) diff --git a/openHABWatch Extension/Views/Utils/IconView.swift b/openHABWatch Extension/Views/Utils/IconView.swift index 9a586150b..661b791c2 100644 --- a/openHABWatch Extension/Views/Utils/IconView.swift +++ b/openHABWatch Extension/Views/Utils/IconView.swift @@ -24,7 +24,8 @@ struct IconView: View { version: 2, icon: widget.icon, state: widget.item?.state ?? "", - iconType: .png + iconType: .png, + iconColor: "" ).url }