Changes
3 changed files (+31/-31)
-
-
@@ -20,7 +20,7 @@ import osenum MainViewState { case loading case found(CoreServer) case found(Connection) case findError(PlacKit.plac_discovery_scan_result_code) case null_pointer case not_found
-
@@ -39,8 +39,8 @@ VStack {switch state { case .loading: ProgressView() case .found(let server): ConnectedView(server: server) case .found(let conn): ConnectedView(conn: conn) case .findError(_): ContentUnavailableView { Label(
-
@@ -102,7 +102,7 @@ return} DispatchQueue.main.async { state = .found(result.entries[0]) state = .found(Connection(server: result.entries[0])) } } }
-
@@ -116,7 +116,7 @@ case authorized(zone_id: String?, zones: [String: TZone])} struct ConnectedView: View { private var conn: Connection let conn: Connection @State private var zone_id: String? = nil @State private var zones: [String: CoreZone] = [:]
-
@@ -148,10 +148,6 @@ PureConnectedView(state: state).onAppear { startLoop() } } init(server: CoreServer) { conn = Connection(server: server) } func startLoop() {
-
-
-
@@ -19,14 +19,10 @@ import SwiftUIimport os struct ServerDiscovery: View { @Environment(\.openWindow) private var openWindow @Environment(\.dismissWindow) private var dismissWindow @State private var servers: [CoreServer] = [] @State private var status: ServerDiscoverySceneListStatus = .loading @AppStorage("PlacApp.connectedServerId") private var connectedServerId: String? var onConnectAction: ((CoreServer) -> Void)? private let logger = Logger() private let queue = DispatchQueue(label: "plac.server-discovery")
-
@@ -40,17 +36,10 @@ scan()} ) .onConnect { server in connectedServerId = server.id openWindow(id: "main-window", value: server.id) dismissWindow(id: "discovery-window") onConnectAction?(server) } .onAppear { if let connectedServerId = connectedServerId { openWindow(id: "main-window", value: connectedServerId) dismissWindow(id: "discovery-window") } else { scan() } scan() } }
-
@@ -81,6 +70,16 @@ status = .loadedservers = result.entries } } } } extension ServerDiscovery { func onConnect(_ handler: @escaping (CoreServer) -> Void) -> ServerDiscovery { var new = self new.onConnectAction = handler return new } }
-
-
-
@@ -18,15 +18,20 @@ import SwiftUI@main struct placApp: App { @AppStorage("PlacApp.connectedServerId") private var connectedServerId: String? var body: some Scene { WindowGroup("Server Selection", id: "discovery-window") { ServerDiscovery() } // Usually, the number of Roon server on network is 1. .defaultSize(width: 600, height: 300) WindowGroup(id: "main-window", for: CoreServer.ID.self) { $serverId in MainView(serverId: serverId) WindowGroup("Plac", id: "main-window") { if let connectedServerId = connectedServerId { MainView(serverId: connectedServerId) } else { ServerDiscovery() .onConnect { server in connectedServerId = server.id } } } .defaultSize(width: 800, height: 600) } }
-