mirror of
https://github.com/jeremysrand/ListenerApp.git
synced 2024-09-27 05:55:10 +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 {
|
struct ContentView: View {
|
||||||
@State private var listening = false
|
@State private var listening = false
|
||||||
|
@State private var listenEnabled = false
|
||||||
@State private var textHeard = ""
|
@State private var textHeard = ""
|
||||||
|
@State private var ipAddress = ""
|
||||||
|
@State private var isEditing = false
|
||||||
|
|
||||||
private let speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: "en-US"))!
|
private let speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: "en-US"))!
|
||||||
|
|
||||||
@ -22,6 +25,12 @@ struct ContentView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
|
TextField("IP Address", text: $ipAddress) { isEditing in
|
||||||
|
self.isEditing = isEditing
|
||||||
|
} onCommit: {
|
||||||
|
validate(destination: ipAddress)
|
||||||
|
}
|
||||||
|
.padding()
|
||||||
Label(textHeard, systemImage:"")
|
Label(textHeard, systemImage:"")
|
||||||
.labelStyle(TitleOnlyLabelStyle())
|
.labelStyle(TitleOnlyLabelStyle())
|
||||||
.padding()
|
.padding()
|
||||||
@ -31,9 +40,14 @@ struct ContentView: View {
|
|||||||
.padding()
|
.padding()
|
||||||
.background(listening ? Color.red : Color.white)
|
.background(listening ? Color.red : Color.white)
|
||||||
.foregroundColor(listening ? .black : .blue)
|
.foregroundColor(listening ? .black : .blue)
|
||||||
|
.disabled(listenEnabled == false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func validate(destination : String) {
|
||||||
|
listenEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
func listen() {
|
func listen() {
|
||||||
self.listening.toggle()
|
self.listening.toggle()
|
||||||
if (self.listening) {
|
if (self.listening) {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0</string>
|
<string>1.0</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>29</string>
|
<string>36</string>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSSpeechRecognitionUsageDescription</key>
|
<key>NSSpeechRecognitionUsageDescription</key>
|
||||||
|
Loading…
Reference in New Issue
Block a user