46 lines
1.4 KiB
Swift
46 lines
1.4 KiB
Swift
|
|
import SwiftUI
|
||
|
|
|
||
|
|
@main
|
||
|
|
struct PadXcodeDaemonApp: App {
|
||
|
|
|
||
|
|
@StateObject private var preferences = AppPreferences()
|
||
|
|
@State private var controller: DaemonController
|
||
|
|
|
||
|
|
init() {
|
||
|
|
ensureConfigFile()
|
||
|
|
let prefs = AppPreferences()
|
||
|
|
_preferences = StateObject(wrappedValue: prefs)
|
||
|
|
_controller = State(wrappedValue: DaemonController(preferences: prefs))
|
||
|
|
}
|
||
|
|
|
||
|
|
var body: some Scene {
|
||
|
|
MenuBarExtra {
|
||
|
|
MenuBarView(controller: controller, preferences: preferences)
|
||
|
|
.task {
|
||
|
|
// Start daemon on first appearance if not already running
|
||
|
|
if !controller.serverState.isRunning {
|
||
|
|
await controller.start()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} label: {
|
||
|
|
MenuBarIcon(controller: controller)
|
||
|
|
}
|
||
|
|
.menuBarExtraStyle(.window)
|
||
|
|
|
||
|
|
Window("PadXcode Daemon Settings", id: "settings") {
|
||
|
|
DaemonSettingsView(controller: controller, preferences: preferences)
|
||
|
|
}
|
||
|
|
.windowResizability(.contentSize)
|
||
|
|
.defaultSize(width: 520, height: 580)
|
||
|
|
.windowStyle(.titleBar)
|
||
|
|
.commandsRemoved()
|
||
|
|
|
||
|
|
Window("Daemon Log", id: "log") {
|
||
|
|
DaemonLogWindowView(controller: controller)
|
||
|
|
}
|
||
|
|
.defaultSize(width: 700, height: 500)
|
||
|
|
.windowStyle(.titleBar)
|
||
|
|
.commandsRemoved()
|
||
|
|
}
|
||
|
|
}
|