-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathGeneralSettingsView.swift
More file actions
63 lines (58 loc) · 2.33 KB
/
GeneralSettingsView.swift
File metadata and controls
63 lines (58 loc) · 2.33 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
51
52
53
54
55
56
57
58
59
60
61
62
63
import ComposableArchitecture
import SwiftUI
struct GeneralSettingsView: View {
@Environment(\.updateChecker) var updateChecker
@AppStorage(\.extensionPermissionShown) var extensionPermissionShown: Bool
@AppStorage(\.quitXPCServiceOnXcodeAndAppQuit) var quitXPCServiceOnXcodeAndAppQuit: Bool
@State private var shouldPresentExtensionPermissionAlert = false
let store: StoreOf<General>
var accessibilityPermissionSubtitle: String {
guard let granted = store.isAccessibilityPermissionGranted else { return "Loading..." }
return granted ? "Granted" : "Not Granted. Required to run. Click to open System Preferences."
}
var body: some View {
SettingsSection(title: "General") {
SettingsToggle(
title: "Quit GitHub Copilot when Xcode App is closed",
isOn: $quitXPCServiceOnXcodeAndAppQuit
)
Divider()
SettingsLink(
url: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility",
title: "Accessibility Permission",
subtitle: accessibilityPermissionSubtitle
)
Divider()
SettingsLink(
url: "x-apple.systempreferences:com.apple.ExtensionsPreferences",
title: "Extension Permission",
subtitle: """
Check for GitHub Copilot in Xcode's Editor menu. \
Restart Xcode if greyed out.
"""
)
}
.alert(
"Enable Extension Permission",
isPresented: $shouldPresentExtensionPermissionAlert
) {
Button("Open System Preferences", action: {
let url = "x-apple.systempreferences:com.apple.ExtensionsPreferences"
NSWorkspace.shared.open(URL(string: url)!)
}).keyboardShortcut(.defaultAction)
Button("Close", role: .cancel, action: {})
} message: {
Text("Enable GitHub Copilot under Xcode Source Editor extensions")
}
.task {
if extensionPermissionShown { return }
extensionPermissionShown = true
shouldPresentExtensionPermissionAlert = true
}
}
}
#Preview {
GeneralSettingsView(
store: .init(initialState: .init(), reducer: { General() })
)
}