-
Notifications
You must be signed in to change notification settings - Fork 43
/
EnsembleApp.swift
57 lines (49 loc) · 1.11 KB
/
EnsembleApp.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// EnsembleApp.swift
// visionOS
//
// Created by Saagar Jha on 10/8/23.
//
import SwiftUI
@main
struct EnsembleApp: App {
@State
var remote: Remote?
// This needs to be available "immedidately" because when the binding
// updates it will consult this list, and @State will have a stale value.
class _State {
var windows = [Window.ID: Window]()
}
let state = _State()
@Preference(\.persistedHistoricalLogs)
var persistedHistoricalLogs
init() {
Log.pruneLogs(count: persistedHistoricalLogs)
}
var body: some Scene {
WindowGroup("Window", id: "window", for: Window.ID.self) { $window in
if let remote {
let selectedWindow = Binding(
get: {
$window.wrappedValue.flatMap {
state.windows[$0]
}
},
set: {
if let window = $0 {
state.windows[window.id] = window
$window.wrappedValue = window.id
}
})
ContentView(remote: remote, selectedWindow: selectedWindow)
} else {
ConnectionView(remote: $remote)
}
}
.windowStyle(.plain)
.windowResizability(.contentSize)
WindowGroup("Logs", id: "logs") {
LogsView()
}
}
}