2025-12-12 21:18:54 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
|
|
@main
|
2026-01-30 03:15:10 +01:00
|
|
|
struct OpenClawApp: App {
|
2025-12-14 05:04:58 +00:00
|
|
|
@State private var appModel: NodeAppModel
|
2026-01-19 05:44:36 +00:00
|
|
|
@State private var gatewayController: GatewayConnectionController
|
2025-12-12 21:18:54 +00:00
|
|
|
@Environment(\.scenePhase) private var scenePhase
|
|
|
|
|
|
2025-12-14 00:23:34 +00:00
|
|
|
init() {
|
2026-01-19 05:44:36 +00:00
|
|
|
GatewaySettingsStore.bootstrapPersistence()
|
2025-12-14 00:23:34 +00:00
|
|
|
let appModel = NodeAppModel()
|
2025-12-14 05:04:58 +00:00
|
|
|
_appModel = State(initialValue: appModel)
|
2026-01-19 05:44:36 +00:00
|
|
|
_gatewayController = State(initialValue: GatewayConnectionController(appModel: appModel))
|
2025-12-14 00:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
2025-12-12 21:18:54 +00:00
|
|
|
var body: some Scene {
|
|
|
|
|
WindowGroup {
|
2026-02-02 17:27:56 +00:00
|
|
|
RootCanvas()
|
2025-12-14 05:04:58 +00:00
|
|
|
.environment(self.appModel)
|
|
|
|
|
.environment(self.appModel.voiceWake)
|
2026-01-19 05:44:36 +00:00
|
|
|
.environment(self.gatewayController)
|
2025-12-13 01:18:48 +00:00
|
|
|
.onOpenURL { url in
|
|
|
|
|
Task { await self.appModel.handleDeepLink(url: url) }
|
|
|
|
|
}
|
2025-12-12 21:18:54 +00:00
|
|
|
.onChange(of: self.scenePhase) { _, newValue in
|
|
|
|
|
self.appModel.setScenePhase(newValue)
|
2026-01-19 05:44:36 +00:00
|
|
|
self.gatewayController.setScenePhase(newValue)
|
2025-12-12 21:18:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|