mirror of
https://github.com/jeremysrand/ListenerApp.git
synced 2024-12-21 13:29:53 +00:00
Add an IP address textfield and conditionally enable the listen button on validating the IP address (not implemented yet).
This commit is contained in:
parent
7f8328cc9b
commit
65ffb20ac7
@ -10,7 +10,10 @@ import Speech
|
||||
|
||||
struct ContentView: View {
|
||||
@State private var listening = false
|
||||
@State private var listenEnabled = false
|
||||
@State private var textHeard = ""
|
||||
@State private var ipAddress = ""
|
||||
@State private var isEditing = false
|
||||
|
||||
private let speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: "en-US"))!
|
||||
|
||||
@ -22,6 +25,12 @@ struct ContentView: View {
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
TextField("IP Address", text: $ipAddress) { isEditing in
|
||||
self.isEditing = isEditing
|
||||
} onCommit: {
|
||||
validate(destination: ipAddress)
|
||||
}
|
||||
.padding()
|
||||
Label(textHeard, systemImage:"")
|
||||
.labelStyle(TitleOnlyLabelStyle())
|
||||
.padding()
|
||||
@ -31,9 +40,14 @@ struct ContentView: View {
|
||||
.padding()
|
||||
.background(listening ? Color.red : Color.white)
|
||||
.foregroundColor(listening ? .black : .blue)
|
||||
.disabled(listenEnabled == false)
|
||||
}
|
||||
}
|
||||
|
||||
func validate(destination : String) {
|
||||
listenEnabled = true
|
||||
}
|
||||
|
||||
func listen() {
|
||||
self.listening.toggle()
|
||||
if (self.listening) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>29</string>
|
||||
<string>36</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSSpeechRecognitionUsageDescription</key>
|
||||
|
Loading…
Reference in New Issue
Block a user