forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.swift
More file actions
51 lines (45 loc) · 1.48 KB
/
App.swift
File metadata and controls
51 lines (45 loc) · 1.48 KB
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
import Client
import HostApp
import LaunchAgentManager
import SwiftUI
import UpdateChecker
import XPCShared
struct VisualEffect: NSViewRepresentable {
func makeNSView(context: Self.Context) -> NSView { return NSVisualEffectView() }
func updateNSView(_ nsView: NSView, context: Context) {}
}
class TheUpdateCheckerDelegate: UpdateCheckerDelegate {
func prepareForRelaunch(finish: @escaping () -> Void) {
Task {
let service = try? getService()
try? await service?.quitService()
finish()
}
}
}
let updateCheckerDelegate = TheUpdateCheckerDelegate()
@main
struct CopilotForXcodeApp: App {
var body: some Scene {
WindowGroup {
TabContainer()
.frame(minWidth: 800, minHeight: 600)
.background(VisualEffect().ignoresSafeArea())
.onAppear {
UserDefaults.setupDefaultSettings()
}
.environment(
\.updateChecker,
{
let checker = UpdateChecker(
hostBundle: Bundle.main,
shouldAutomaticallyCheckForUpdate: false
)
checker.updateCheckerDelegate = updateCheckerDelegate
return checker
}()
)
}
}
}
var isPreview: Bool { ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" }