Changes
3 changed files (+40/-0)
-
-
@@ -14,6 +14,7 @@ // limitations under the License.// // SPDX-License-Identifier: Apache-2.0 import Observation import PlacKit import os
-
@@ -57,6 +58,7 @@ case connected(ConnectedEvent)case zoneList(ZoneListEvent) } @Observable class Connection { let logger = Logger()
-
@@ -107,5 +109,9 @@ }func subscribeZoneChanges() { PlacKit.plac_connection_subscribe_zones(ptr) } func close() { PlacKit.plac_connection_disconnect(ptr) } }
-
-
-
@@ -148,6 +148,7 @@ PureConnectedView(state: state).onAppear { startLoop() } .focusedSceneValue(conn) } func startLoop() {
-
-
-
@@ -16,6 +16,34 @@ // SPDX-License-Identifier: Apache-2.0import SwiftUI struct ConnectionCommands: Commands { var onDisconnect: (() -> Void)? @FocusedValue(Connection.self) private var conn: Connection? var body: some Commands { CommandGroup(after: .appInfo) { Button("Disconnect", systemImage: "powercode") { // FIXME: "disconnect" call panics with "incorrect alignment" error (at call to "deinitListeners") if let conn = conn { conn.close() } onDisconnect?() } .disabled(true) } CommandGroup(before: .appTermination) { Button("Disconnect and Quit Plac") { onDisconnect?() NSApp.terminate(nil) } } } } @main struct placApp: App { @AppStorage("PlacApp.connectedServerId") private var connectedServerId:
-
@@ -31,6 +59,11 @@ .onConnect { server inconnectedServerId = server.id } } } .commands { ConnectionCommands(onDisconnect: { connectedServerId = nil }) } .defaultSize(width: 800, height: 600) }
-