ListenerApp/ListenerGS/ContentView.swift

46 lines
1.2 KiB
Swift
Raw Normal View History

2021-07-16 16:46:54 +00:00
//
// ContentView.swift
2021-09-16 02:42:53 +00:00
// ListenerGS
2021-07-16 16:46:54 +00:00
//
// Created by Jeremy Rand on 2021-07-16.
//
import SwiftUI
import Speech
2021-07-16 16:46:54 +00:00
struct ContentView: View {
@StateObject private var speechForwarder = SpeechForwarder()
2021-07-16 16:46:54 +00:00
var body: some View {
VStack {
TextField("IP Address", text: $speechForwarder.ipAddress) { isEditing in
speechForwarder.isEditing = isEditing
} onCommit: {
speechForwarder.validate(destination: speechForwarder.ipAddress)
}
.padding()
2021-07-17 03:20:52 +00:00
ScrollView() {
Text(speechForwarder.log)
.multilineTextAlignment(.leading)
}
2021-07-17 03:20:52 +00:00
Button("Listen") {
speechForwarder.listen()
}
2021-07-17 03:20:52 +00:00
.padding()
.background(speechForwarder.listening ? Color.red : Color.clear)
.foregroundColor(speechForwarder.listening ? .black : .blue)
.disabled(speechForwarder.listenEnabled == false)
2021-07-17 03:20:52 +00:00
.frame(maxWidth: .infinity)
.buttonStyle(PlainButtonStyle())
}
}
2021-07-16 16:46:54 +00:00
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}