Skip to content

Commit

Permalink
Merge branch 'develop' into icon-out-of-range-index
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaldan authored Oct 16, 2023
2 parents 3331a5f + 2c45224 commit 3fc199f
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 29 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[1]
}
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
40 changes: 20 additions & 20 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 All @@ -1600,7 +1600,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
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 @@ -1611,7 +1611,7 @@
"@executable_path/Frameworks",
"@loader_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.openHABUITests;
Expand Down Expand Up @@ -1642,7 +1642,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1580410537;
CURRENT_PROJECT_VERSION = 1580410538;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = PBAPXHRAM9;
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand All @@ -1653,7 +1653,7 @@
"@executable_path/Frameworks",
"@loader_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.openHABUITests;
Expand Down Expand Up @@ -1684,7 +1684,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
"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 @@ -1695,7 +1695,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 @@ -1729,7 +1729,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
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 @@ -1740,7 +1740,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 @@ -1771,7 +1771,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "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 @@ -1782,7 +1782,7 @@
"@executable_path/Frameworks",
"@loader_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 = "com.reg-labs.openHABTestsSwift";
Expand Down Expand Up @@ -1814,7 +1814,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1580410537;
CURRENT_PROJECT_VERSION = 1580410538;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = PBAPXHRAM9;
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand All @@ -1825,7 +1825,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
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 @@ -1968,7 +1968,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;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = PBAPXHRAM9;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand All @@ -1984,7 +1984,7 @@
"@loader_path/../../Frameworks",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
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 @@ -2013,7 +2013,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 All @@ -2029,7 +2029,7 @@
"@loader_path/../../Frameworks",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
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 3fc199f

Please sign in to comment.