-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
AutoCompletionView.swift
39 lines (36 loc) · 974 Bytes
/
AutoCompletionView.swift
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
import SwiftUI
struct AutoCompletionView: View {
@ObservedObject var store: AutoCompletionStore
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 0) {
ForEach(store.completions, id: \.self) { completion in
HStack {
Text(completion)
Spacer()
}
.font(.caption.monospaced())
.padding(4)
.background(store.selection == completion
? Color.accentColor.opacity(0.5)
: Color.clear)
.cornerRadius(4)
.frame(height: 16)
}
}
}
.padding(4)
.overlay(
RoundedRectangle(cornerRadius: 4)
.stroke(Color(.controlColor))
)
.cornerRadius(4)
}
}
struct AutoCompletionView_Previews: PreviewProvider {
static var previews: some View {
AutoCompletionView(store: Self.autoCompletionStore([
"foo", "bar", "baz"
], selection: "foo"))
}
}