forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPIKeyPicker.swift
More file actions
50 lines (43 loc) · 1.63 KB
/
APIKeyPicker.swift
File metadata and controls
50 lines (43 loc) · 1.63 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
import ComposableArchitecture
import SwiftUI
struct APIKeyPicker: View {
@Perception.Bindable var store: StoreOf<APIKeySelection>
var body: some View {
WithPerceptionTracking {
HStack {
Picker(
selection: $store.apiKeyName,
content: {
Text("No API Key").tag("")
if store.availableAPIKeyNames.isEmpty {
Text("No API key found, please add a new one →")
}
if !store.availableAPIKeyNames.contains(store.apiKeyName),
!store.apiKeyName.isEmpty
{
Text("Key not found: \(store.apiKeyName)")
.tag(store.apiKeyName)
}
ForEach(store.availableAPIKeyNames, id: \.self) { name in
Text(name).tag(name)
}
},
label: { Text("API Key") }
)
Button(action: { store.send(.manageAPIKeysButtonClicked) }) {
Text(Image(systemName: "key"))
}
}.sheet(isPresented: $store.isAPIKeyManagementPresented) {
WithPerceptionTracking {
APIKeyManagementView(store: store.scope(
state: \.apiKeyManagement,
action: \.apiKeyManagement
))
}
}
.onAppear {
store.send(.appear)
}
}
}
}