Skip to content

Commit

Permalink
Migrate from WatchKit storyboard to SwiftUI and its lifecycle (#739)
Browse files Browse the repository at this point in the history
* Migration of watch app to SwiftUI and its lifecycle
* Handling of svg images on watchOS with SDWebImage, removed Kingfisher as dependency in watch app.
* Replace watch tracker with global network tracker


Co-authored-by: Dan Cunningham <[email protected]>
Signed-off-by: Tim Bert <[email protected]>
  • Loading branch information
timbms and digitaldan authored Oct 30, 2024
1 parent eb34c7f commit f823734
Show file tree
Hide file tree
Showing 136 changed files with 1,980 additions and 1,620 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ openHAB.ipa
build/
BuildTools/.build
OpenHABCore/Package.resolved

swift-openapi-generator/
OpenHABCore/swift-openapi-generator/
1 change: 1 addition & 0 deletions BuildTools/.swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
--exclude ../fastlane
--exclude ../OpenHABCore/.build
--exclude ./build
--exclude ../OpenHABCore/swift-openapi-generator
--symlinks ignore

# disabled rules
Expand Down
4 changes: 2 additions & 2 deletions BuildTools/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/weakfl/SwiftFormatPlugin",
"state" : {
"revision" : "29d6c0bc4c078f819504d92fb5b359e63fd32046",
"version" : "0.53.2"
"revision" : "65e4f4aaba165f03f311bd1472b771988f11828e",
"version" : "0.54.3"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion BuildTools/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let package = Package(
name: "BuildTools",
platforms: [.macOS(.v10_13)],
dependencies: [
.package(url: "https://github.com/weakfl/SwiftFormatPlugin", exact: "0.53.2"),
.package(url: "https://github.com/weakfl/SwiftFormatPlugin", exact: "0.54.3"),
.package(url: "https://github.com/weakfl/SwiftLintPlugin.git", exact: "0.54.0")
],
targets: [
Expand Down
1 change: 0 additions & 1 deletion OpenHABCore/Sources/OpenHABCore/Model/OpenHABWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
//
// SPDX-License-Identifier: EPL-2.0

import Alamofire
import Foundation
import MapKit
import os.log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Foundation
import os.log
import Security

public protocol ClientCertificateManagerDelegate: NSObjectProtocol {
public protocol ClientCertificateManagerDelegate: AnyObject {
// delegate should ask user for a decision on whether to import the client certificate into the keychain
func askForClientCertificateImport(_ clientCertificateManager: ClientCertificateManager?)
// delegate should ask user for the export password used to decode the PKCS#12
Expand Down
1 change: 1 addition & 0 deletions OpenHABCore/Sources/OpenHABCore/Util/NetworkTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public final class NetworkTracker: ObservableObject {
public func startTracking(connectionConfigurations: [ConnectionConfiguration], username: String, password: String, alwaysSendBasicAuth: Bool) {
self.connectionConfigurations = connectionConfigurations
httpClient = HTTPClient(username: username, password: password, alwaysSendBasicAuth: alwaysSendBasicAuth)
setActiveConnection(nil)
attemptConnection()
}

Expand Down
1 change: 1 addition & 0 deletions OpenHABCore/Sources/OpenHABCore/Util/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public enum Preferences {
@UserDefault("sortSitemapsBy", defaultValue: 0) public static var sortSitemapsby: Int
@UserDefault("defaultMainUIPath", defaultValue: "") public static var defaultMainUIPath: String
@UserDefault("alwaysAllowWebRTC", defaultValue: false) public static var alwaysAllowWebRTC: Bool
@UserDefault("sitemapForWatch", defaultValue: "watch") public static var sitemapForWatch: String

// MARK: - Private

Expand Down
2 changes: 2 additions & 0 deletions OpenHABCore/Tests/OpenHABCoreTests/UserDefaultsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ final class UserDefaultsTests: XCTestCase {
Preferences.idleOff = Preferences.idleOff
Preferences.iconType = Preferences.iconType
Preferences.defaultSitemap = Preferences.defaultSitemap
Preferences.sitemapForWatch = Preferences.sitemapForWatch
}

// Testing the consistency between properties of Preferences and the corresponding entry in UserDefaults
Expand All @@ -45,5 +46,6 @@ final class UserDefaultsTests: XCTestCase {
XCTAssertEqual(Preferences.idleOff, data.bool(forKey: "idleOff"))
XCTAssertEqual(Preferences.iconType, data.integer(forKey: "iconType"))
XCTAssertEqual(Preferences.defaultSitemap, data.string(forKey: "defaultSitemap"))
XCTAssertEqual(Preferences.sitemapForWatch, data.string(forKey: "sitemapForWatch"))
}
}
528 changes: 445 additions & 83 deletions openHAB.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
{
"originHash" : "3e04d0efd248e4773eeea4bddf4c08890d8cb5b0c615e3a2ff865ffe7b192275",
"pins" : [
{
"identity" : "abseil-cpp-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/abseil-cpp-binary.git",
"state" : {
"revision" : "194a6706acbd25e4ef639bcaddea16e8758a3e27",
"version" : "1.2024011602.0"
}
},
{
"identity" : "alamofire",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Alamofire/Alamofire.git",
"state" : {
"revision" : "f455c2975872ccd2d9c81594c658af65716e9b9a",
"version" : "5.9.1"
}
},
{
"identity" : "alamofirenetworkactivityindicator",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Alamofire/AlamofireNetworkActivityIndicator.git",
"state" : {
"revision" : "392bed083e8d193aca16bfa684ee24e4bcff0510",
"version" : "3.1.0"
}
},
{
"identity" : "app-check",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/app-check.git",
"state" : {
"revision" : "3b62f154d00019ae29a71e9738800bb6f18b236d",
"version" : "10.19.2"
}
},
{
"identity" : "cocoalumberjack",
"kind" : "remoteSourceControl",
"location" : "https://github.com/CocoaLumberjack/CocoaLumberjack.git",
"state" : {
"revision" : "4b8714a7fb84d42393314ce897127b3939885ec3",
"version" : "3.8.5"
}
},
{
"identity" : "devicekit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/devicekit/DeviceKit.git",
"state" : {
"revision" : "d37e70cb2646666dcf276d7d3d4a9760a41ff8a6",
"version" : "4.9.0"
}
},
{
"identity" : "firebase-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk.git",
"state" : {
"revision" : "eca84fd638116dd6adb633b5a3f31cc7befcbb7d",
"version" : "10.29.0"
}
},
{
"identity" : "flexcolorpicker",
"kind" : "remoteSourceControl",
"location" : "https://github.com/RastislavMirek/FlexColorPicker.git",
"state" : {
"revision" : "72a5c2c5e28074e6c5f13efe3c98eb780ae2f906",
"version" : "1.4.4"
}
},
{
"identity" : "googleappmeasurement",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleAppMeasurement.git",
"state" : {
"revision" : "fe727587518729046fc1465625b9afd80b5ab361",
"version" : "10.28.0"
}
},
{
"identity" : "googledatatransport",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleDataTransport.git",
"state" : {
"revision" : "a637d318ae7ae246b02d7305121275bc75ed5565",
"version" : "9.4.0"
}
},
{
"identity" : "googleutilities",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleUtilities.git",
"state" : {
"revision" : "57a1d307f42df690fdef2637f3e5b776da02aad6",
"version" : "7.13.3"
}
},
{
"identity" : "grpc-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/grpc-binary.git",
"state" : {
"revision" : "e9fad491d0673bdda7063a0341fb6b47a30c5359",
"version" : "1.62.2"
}
},
{
"identity" : "gtm-session-fetcher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/gtm-session-fetcher.git",
"state" : {
"revision" : "a2ab612cb980066ee56d90d60d8462992c07f24b",
"version" : "3.5.0"
}
},
{
"identity" : "interop-ios-for-google-sdks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/interop-ios-for-google-sdks.git",
"state" : {
"revision" : "2d12673670417654f08f5f90fdd62926dc3a2648",
"version" : "100.0.0"
}
},
{
"identity" : "kingfisher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/onevcat/Kingfisher.git",
"state" : {
"revision" : "2ef543ee21d63734e1c004ad6c870255e8716c50",
"version" : "7.12.0"
}
},
{
"identity" : "leveldb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/leveldb.git",
"state" : {
"revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1",
"version" : "1.22.5"
}
},
{
"identity" : "nanopb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/nanopb.git",
"state" : {
"revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1",
"version" : "2.30910.0"
}
},
{
"identity" : "promises",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/promises.git",
"state" : {
"revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac",
"version" : "2.4.0"
}
},
{
"identity" : "sdwebimage",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SDWebImage/SDWebImage.git",
"state" : {
"revision" : "8a1be70a625683bc04d6903e2935bf23f3c6d609",
"version" : "5.19.7"
}
},
{
"identity" : "sdwebimagesvgcoder",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SDWebImage/SDWebImageSVGCoder.git",
"state" : {
"revision" : "950167445ab703740569869c8b7510efc9d09a26",
"version" : "1.7.0"
}
},
{
"identity" : "sdwebimageswiftui",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SDWebImage/SDWebImageSwiftUI.git",
"state" : {
"revision" : "53573d6dd017e354c0e7d8f1c86b77ef1383c996",
"version" : "2.2.7"
}
},
{
"identity" : "sfsafesymbols",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SFSafeSymbols/SFSafeSymbols",
"state" : {
"revision" : "e2e28f4e56e1769c2ec3c61c9355fc64eb7a535a",
"version" : "5.3.0"
}
},
{
"identity" : "sidemenu",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jonkykong/SideMenu.git",
"state" : {
"revision" : "8bd4fd128923cf5494fa726839af8afe12908ad9",
"version" : "6.5.0"
}
},
{
"identity" : "svgkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SVGKit/SVGKit.git",
"state" : {
"branch" : "3.x",
"revision" : "1b8a3cf210ab4681c18fbb62059bbdbb37dd649a"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log",
"state" : {
"revision" : "9cb486020ebf03bfa5b5df985387a14a98744537",
"version" : "1.6.1"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "edb6ed4919f7756157fe02f2552b7e3850a538e5",
"version" : "1.28.1"
}
},
{
"identity" : "swiftmessages",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SwiftKickMobile/SwiftMessages.git",
"state" : {
"revision" : "62e12e138fc3eedf88c7553dd5d98712aa119f40",
"version" : "9.0.9"
}
}
],
"version" : 3
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
launchAutomaticallySubstyle = "8"
notificationPayloadFile = "openHABWatch Extension/PushNotificationPayload.apns">
notificationPayloadFile = "openHABWatch/Extension/PushNotificationPayload.apns">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
Expand All @@ -74,7 +74,7 @@
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
launchAutomaticallySubstyle = "8"
notificationPayloadFile = "openHABWatch Extension/PushNotificationPayload.apns">
notificationPayloadFile = "openHABWatch/Extension/PushNotificationPayload.apns">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
Expand Down
15 changes: 7 additions & 8 deletions openHAB.xcodeproj/xcshareddata/xcschemes/openHABWatch.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
buildForTesting = "NO"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DFB2622618830A3600D3244D"
Expand Down Expand Up @@ -54,7 +54,7 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
notificationPayloadFile = "openHABWatch Extension/PushNotificationPayload.apns">
notificationPayloadFile = "openHABWatch/Extension/PushNotificationPayload.apns">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
Expand All @@ -71,8 +71,7 @@
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
notificationPayloadFile = "openHABWatch Extension/PushNotificationPayload.apns">
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
Expand Down
Loading

0 comments on commit f823734

Please sign in to comment.