-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathProxySection.swift
More file actions
65 lines (60 loc) · 1.87 KB
/
ProxySection.swift
File metadata and controls
65 lines (60 loc) · 1.87 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
64
65
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
)
SettingsTextField(
title: "Proxy username",
prompt: "username",
text: $gitHubCopilotProxyUsername
)
SettingsSecureField(
title: "Proxy password",
prompt: "password",
text: $gitHubCopilotProxyPassword
)
SettingsToggle(
title: "Proxy strict SSL",
isOn: $gitHubCopilotUseStrictSSL
)
} footer: {
HStack {
Spacer()
Button("Refresh configurations") {
refreshConfiguration()
}
}
}
}
func refreshConfiguration() {
NotificationCenter.default.post(
name: .gitHubCopilotShouldRefreshEditorInformation,
object: nil
)
Task {
let service = try getService()
do {
try await service.postNotification(
name: Notification.Name
.gitHubCopilotShouldRefreshEditorInformation.rawValue
)
} catch {
toast(error.localizedDescription, .error)
}
}
}
}
#Preview {
ProxySection()
}