diff --git a/ListenerApp/ContentView.swift b/ListenerApp/ContentView.swift index ef232fe..49086bd 100644 --- a/ListenerApp/ContentView.swift +++ b/ListenerApp/ContentView.swift @@ -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) { diff --git a/ListenerApp/Info.plist b/ListenerApp/Info.plist index 298ef92..51f2e1a 100644 --- a/ListenerApp/Info.plist +++ b/ListenerApp/Info.plist @@ -17,7 +17,7 @@ CFBundleShortVersionString 1.0 CFBundleVersion - 29 + 36 LSRequiresIPhoneOS NSSpeechRecognitionUsageDescription