Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
runner authored and runner committed Sep 4, 2023
2 parents 3c2b75b + 2c45224 commit 2b3e08a
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 17 deletions.
4 changes: 2 additions & 2 deletions OpenHABCore/Sources/OpenHABCore/Model/OpenHABWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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)
}
}

Expand Down
8 changes: 6 additions & 2 deletions OpenHABCore/Sources/OpenHABCore/Util/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: [])
}
Expand All @@ -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
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
28 changes: 20 additions & 8 deletions openHAB.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand All @@ -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;
Expand Down Expand Up @@ -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";
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 = "";
Expand Down
3 changes: 2 additions & 1 deletion openHAB/OpenHABNotificationsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion openHAB/OpenHABSitemapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -679,14 +679,19 @@ 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(
rootUrl: openHABRootUrl,
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
Expand Down
3 changes: 2 additions & 1 deletion openHABWatch Extension/Views/Rows/ImageRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion openHABWatch Extension/Views/Utils/IconView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ struct IconView: View {
version: 2,
icon: widget.icon,
state: widget.item?.state ?? "",
iconType: .png
iconType: .png,
iconColor: ""
).url
}

Expand Down

0 comments on commit 2b3e08a

Please sign in to comment.