forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBingSearchView.swift
More file actions
51 lines (44 loc) · 1.43 KB
/
BingSearchView.swift
File metadata and controls
51 lines (44 loc) · 1.43 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 AppKit
import Client
import OpenAIService
import Preferences
import SuggestionModel
import SwiftUI
final class BingSearchViewSettings: ObservableObject {
@AppStorage(\.bingSearchSubscriptionKey) var bingSearchSubscriptionKey: String
@AppStorage(\.bingSearchEndpoint) var bingSearchEndpoint: String
init() {}
}
struct BingSearchView: View {
@Environment(\.openURL) var openURL
@StateObject var settings = BingSearchViewSettings()
var body: some View {
Form {
Button(action: {
let url = URL(string: "https://www.microsoft.com/bing/apis/bing-web-search-api")!
openURL(url)
}) {
Text("Apply for Subscription Key for Free")
}
SecureField(text: $settings.bingSearchSubscriptionKey, prompt: Text("")) {
Text("Bing Search Subscription Key")
}
.textFieldStyle(.roundedBorder)
TextField(
text: $settings.bingSearchEndpoint,
prompt: Text("https://api.bing.microsoft.com/***")
) {
Text("Bing Search Endpoint")
}.textFieldStyle(.roundedBorder)
}
}
}
struct BingSearchView_Previews: PreviewProvider {
static var previews: some View {
VStack(alignment: .leading, spacing: 8) {
BingSearchView()
}
.frame(height: 800)
.padding(.all, 8)
}
}