forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseURLPicker.swift
More file actions
62 lines (57 loc) · 2.1 KB
/
Copy pathBaseURLPicker.swift
File metadata and controls
62 lines (57 loc) · 2.1 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
import ComposableArchitecture
import SwiftUI
struct BaseURLPicker: View {
let prompt: Text?
let showIsFullURL: Bool
let store: StoreOf<BaseURLSelection>
var body: some View {
WithViewStore(store) { viewStore in
Group {
if showIsFullURL {
Picker(
selection: viewStore.$isFullURL,
content: {
Text("Base URL").tag(false)
Text("Full URL").tag(true)
},
label: { Text("URL") }
)
.pickerStyle(.segmented)
}
HStack {
TextField(
showIsFullURL ? "" : "Base URL",
text: viewStore.$baseURL,
prompt: prompt
)
if viewStore.isFullURL == false {
Text("/v1/chat/completions")
}
}
.padding(.trailing)
.overlay(alignment: .trailing) {
Picker(
"",
selection: viewStore.$baseURL,
content: {
if !viewStore.state.availableBaseURLs
.contains(viewStore.state.baseURL),
!viewStore.state.baseURL.isEmpty
{
Text("Custom Value").tag(viewStore.state.baseURL)
}
Text("Empty (Default Value)").tag("")
ForEach(viewStore.state.availableBaseURLs, id: \.self) { baseURL in
Text(baseURL).tag(baseURL)
}
}
)
.frame(width: 20)
}
}
.onAppear {
viewStore.send(.appear)
}
}
}
}