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
35 lines (31 loc) · 1.13 KB
/
BaseURLPicker.swift
File metadata and controls
35 lines (31 loc) · 1.13 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
import ComposableArchitecture
import SwiftUI
struct BaseURLPicker: View {
let prompt: Text?
let store: StoreOf<BaseURLSelection>
var body: some View {
WithViewStore(store) { viewStore in
TextField("Base URL", text: viewStore.$baseURL, prompt: prompt)
.overlay(alignment: .trailing) {
Picker(
"",
selection: viewStore.$baseURL,
content: {
if !viewStore.state.availableBaseURLs
.contains(viewStore.state.baseURL)
{
Text("Custom Value").tag(viewStore.state.baseURL)
}
ForEach(viewStore.state.availableBaseURLs, id: \.self) { baseURL in
Text(baseURL).tag(baseURL)
}
}
)
.frame(width: 20)
}
.onAppear {
viewStore.send(.appear)
}
}
}
}