-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathProxySection.swift
More file actions
63 lines (58 loc) · 2 KB
/
ProxySection.swift
File metadata and controls
63 lines (58 loc) · 2 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 Client
import SwiftUI
import Toast
struct ProxySection: View {
@AppStorage(\.gitHubCopilotProxyUrl) var gitHubCopilotProxyUrl
@AppStorage(\.gitHubCopilotProxyUsername) var gitHubCopilotProxyUsername
@AppStorage(\.gitHubCopilotProxyPassword) var gitHubCopilotProxyPassword
@AppStorage(\.gitHubCopilotUseStrictSSL) var gitHubCopilotUseStrictSSL
@Environment(\.toast) var toast
var body: some View {
SettingsSection(title: "Proxy") {
SettingsTextField(
title: "Proxy URL",
prompt: "http://host:port",
text: $gitHubCopilotProxyUrl,
onDebouncedChange: { _ in refreshConfiguration() }
)
SettingsTextField(
title: "Proxy username",
prompt: "username",
text: $gitHubCopilotProxyUsername,
onDebouncedChange: { _ in refreshConfiguration() }
)
SettingsTextField(
title: "Proxy password",
prompt: "password",
text: $gitHubCopilotProxyPassword,
isSecure: true,
onDebouncedChange: { _ in refreshConfiguration() }
)
SettingsToggle(
title: "Proxy strict SSL",
isOn: $gitHubCopilotUseStrictSSL
)
.onChange(of: gitHubCopilotUseStrictSSL) { _ in refreshConfiguration() }
}
}
func refreshConfiguration() {
NotificationCenter.default.post(
name: .gitHubCopilotShouldRefreshEditorInformation,
object: nil
)
Task {
do {
let service = try getService()
try await service.postNotification(
name: Notification.Name
.gitHubCopilotShouldRefreshEditorInformation.rawValue
)
} catch {
toast(error.localizedDescription, .error)
}
}
}
}
#Preview {
ProxySection()
}