-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextFieldExample.swift
More file actions
33 lines (28 loc) · 846 Bytes
/
TextFieldExample.swift
File metadata and controls
33 lines (28 loc) · 846 Bytes
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
//
// SwiftUIView.swift
//
//
// Created by Simon Lion on 29.08.21.
//
import SwiftUI
import UserPrediction
struct SwiftUIView: View {
@State var userTextInput = ""
let mySearchable = ["String","Strin","Stri","Str","St","S","X"]
var precition = []
var body: some View {
TextField("Title", text: $userTextInput, onEditingChanged: { editing in
UserPrediction.predictContinuous(input: $userTextInput, in: self.mySearchable, while: editing) { completion in
print("Prediction: ", completion)
}
},
onCommit: {
self.precition = UserPrediction.predict(input: self.userTextInput, in: self.mySearchable)
}).padding()
}
}
struct SwiftUIView_Previews: PreviewProvider {
static var previews: some View {
SwiftUIView()
}
}