41 lines
1.5 KiB
Swift
41 lines
1.5 KiB
Swift
|
|
import SwiftUI
|
||
|
|
import Foundation
|
||
|
|
|
||
|
|
@main
|
||
|
|
struct PadXcodeApp: App {
|
||
|
|
@StateObject private var daemonConfig = DaemonConfiguration()
|
||
|
|
@StateObject private var projectStore = ProjectStore()
|
||
|
|
@StateObject private var editorState = EditorState()
|
||
|
|
@StateObject private var gitStore = GitStore()
|
||
|
|
@StateObject private var lspClient: LSPClient
|
||
|
|
|
||
|
|
private let gitService: GitService
|
||
|
|
private let gitCallbackHandler: GitCallbackHandler
|
||
|
|
|
||
|
|
init() {
|
||
|
|
let config = DaemonConfiguration()
|
||
|
|
let apiKey = UserDefaults.standard.string(forKey: "workingCopyAPIKey") ?? ""
|
||
|
|
let store = GitStore()
|
||
|
|
_daemonConfig = StateObject(wrappedValue: config)
|
||
|
|
_lspClient = StateObject(wrappedValue: LSPClient(config: config))
|
||
|
|
_gitStore = StateObject(wrappedValue: store)
|
||
|
|
gitService = GitService(apiKey: apiKey)
|
||
|
|
gitCallbackHandler = GitCallbackHandler(store: store)
|
||
|
|
}
|
||
|
|
|
||
|
|
var body: some Scene {
|
||
|
|
WindowGroup {
|
||
|
|
ContentView(gitService: gitService)
|
||
|
|
.environmentObject(daemonConfig)
|
||
|
|
.environmentObject(projectStore)
|
||
|
|
.environmentObject(editorState)
|
||
|
|
.environmentObject(gitStore)
|
||
|
|
.environmentObject(lspClient)
|
||
|
|
.onOpenURL { url in
|
||
|
|
Task { @MainActor in gitCallbackHandler.handle(url: url) }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.commands { CommandGroup(replacing: .undoRedo) { } }
|
||
|
|
}
|
||
|
|
}
|