Skip to content

Commit

Permalink
Migration of watch app to SwiftUI and its lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
timbms committed Nov 7, 2023
1 parent 20947ad commit 847fb36
Show file tree
Hide file tree
Showing 113 changed files with 668 additions and 382 deletions.
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 Fuzi
import MapKit
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Alamofire
import Foundation
import os.log

public protocol ServerCertificateManagerDelegate: NSObjectProtocol {
public protocol ServerCertificateManagerDelegate: AnyObject {
// delegate should ask user for a decision on what to do with invalid certificate
func evaluateServerTrust(_ policy: ServerCertificateManager?, summary certificateSummary: String?, forDomain domain: String?)
// certificate received from openHAB doesn't match our record, ask user for a decision
Expand Down
429 changes: 356 additions & 73 deletions openHAB.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

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
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
notificationPayloadFile = "openHABWatch Extension/PushNotificationPayload.apns">
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
Expand All @@ -71,8 +70,7 @@
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
notificationPayloadFile = "openHABWatch Extension/PushNotificationPayload.apns">
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
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 @@ -15,8 +15,8 @@
"repositoryURL": "https://github.com/Alamofire/Alamofire.git",
"state": {
"branch": null,
"revision": "d120af1e8638c7da36c8481fd61a66c0c08dc4fc",
"version": "5.4.4"
"revision": "b2fa556e4e48cbf06cf8c63def138c98f4b811fa",
"version": "5.8.0"
}
},
{
Expand Down
31 changes: 0 additions & 31 deletions openHABWatch Extension/HostingController.swift

This file was deleted.

20 changes: 0 additions & 20 deletions openHABWatch Extension/PreferencesHostingController.swift

This file was deleted.

5 changes: 0 additions & 5 deletions openHABWatch Extension/openHABWatch Extension.entitlements

This file was deleted.

18 changes: 0 additions & 18 deletions openHABWatch Extension/openHABWatch Extension/app/AppState.swift

This file was deleted.

92 changes: 10 additions & 82 deletions openHABWatch/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,92 +1,20 @@
{
"images" : [
{
"size" : "24x24",
"idiom" : "watch",
"filename" : "Icon-24@2x.png",
"scale" : "2x",
"role" : "notificationCenter",
"subtype" : "38mm"
"filename" : "ItunesArtwork@2x 1.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"size" : "27.5x27.5",
"idiom" : "watch",
"filename" : "Icon-27.5@2x.png",
"scale" : "2x",
"role" : "notificationCenter",
"subtype" : "42mm"
},
{
"size" : "29x29",
"idiom" : "watch",
"filename" : "Icon-29@2x.png",
"role" : "companionSettings",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "watch",
"filename" : "Icon-29@3x.png",
"role" : "companionSettings",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "watch",
"filename" : "Icon-40@2x.png",
"scale" : "2x",
"role" : "appLauncher",
"subtype" : "38mm"
},
{
"size" : "44x44",
"idiom" : "watch",
"filename" : "icon-88.png",
"scale" : "2x",
"role" : "appLauncher",
"subtype" : "40mm"
},
{
"size" : "50x50",
"idiom" : "watch",
"filename" : "icon-100.png",
"scale" : "2x",
"role" : "appLauncher",
"subtype" : "44mm"
},
{
"size" : "86x86",
"idiom" : "watch",
"filename" : "Icon-86@2x.png",
"scale" : "2x",
"role" : "quickLook",
"subtype" : "38mm"
},
{
"size" : "98x98",
"idiom" : "watch",
"filename" : "Icon-98@2x.png",
"scale" : "2x",
"role" : "quickLook",
"subtype" : "42mm"
},
{
"size" : "108x108",
"idiom" : "watch",
"filename" : "icon-216@2x.png",
"scale" : "2x",
"role" : "quickLook",
"subtype" : "44mm"
},
{
"size" : "1024x1024",
"idiom" : "watch-marketing",
"filename" : "ItunesArtwork@2x.png",
"scale" : "1x"
"idiom" : "universal",
"platform" : "watchos",
"size" : "1024x1024"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions openHABWatch/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class OpenHABWatchTracker: NSObject {
connectivityTask.cancel()
}
let request = URLRequest(url: URL(string: ObservableOpenHABDataObject.shared.localUrl)!, cachePolicy: .reloadIgnoringCacheData, timeoutInterval: 2.0)
if NetworkConnection.shared == nil {
NetworkConnection.initialize(ignoreSSL: Preferences.ignoreSSL, interceptor: nil)
}
connectivityTask = NetworkConnection.shared.manager.request(request)
.validate()
.responseData { response in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extension OpenHABCore.Future where Value == ObservableOpenHABSitemapPage.CodingD
}

final class UserData: ObservableObject {
static let shared = UserData()
@Published var widgets: [ObservableOpenHABWidget] = []
@Published var showAlert = false
@Published var errorDescription = ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,53 @@
{
"assets" : [
{
"idiom" : "watch",
"filename" : "Circular.imageset",
"idiom" : "watch",
"role" : "circular"
},
{
"idiom" : "watch",
"filename" : "Extra Large.imageset",
"idiom" : "watch",
"role" : "extra-large"
},
{
"idiom" : "watch",
"filename" : "Graphic Bezel.imageset",
"idiom" : "watch",
"role" : "graphic-bezel"
},
{
"idiom" : "watch",
"filename" : "Graphic Circular.imageset",
"idiom" : "watch",
"role" : "graphic-circular"
},
{
"idiom" : "watch",
"filename" : "Graphic Corner.imageset",
"idiom" : "watch",
"role" : "graphic-corner"
},
{
"filename" : "Graphic Extra Large.imageset",
"idiom" : "watch",
"role" : "graphic-extra-large"
},
{
"filename" : "Graphic Large Rectangular.imageset",
"idiom" : "watch",
"role" : "graphic-large-rectangular"
},
{
"idiom" : "watch",
"filename" : "Modular.imageset",
"idiom" : "watch",
"role" : "modular"
},
{
"idiom" : "watch",
"filename" : "Utilitarian.imageset",
"idiom" : "watch",
"role" : "utilitarian"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"images" : [
{
"idiom" : "watch",
"scale" : "2x"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">183"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"auto-scaling" : "auto"
}
}
File renamed without changes.
Loading

0 comments on commit 847fb36

Please sign in to comment.