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
|
2021-07-17 02:58:41 +00:00
|
|
|
import Speech
|
2021-07-16 16:46:54 +00:00
|
|
|
|
|
|
|
struct ContentView: View {
|
2021-10-19 04:48:37 +00:00
|
|
|
@StateObject private var speechForwarder = SpeechForwarder()
|
2021-07-17 02:58:41 +00:00
|
|
|
|
2021-07-16 16:46:54 +00:00
|
|
|
var body: some View {
|
2021-07-17 02:58:41 +00:00
|
|
|
VStack {
|
2021-10-19 04:48:37 +00:00
|
|
|
TextField("IP Address", text: $speechForwarder.ipAddress) { isEditing in
|
|
|
|
speechForwarder.isEditing = isEditing
|
2021-07-17 03:12:01 +00:00
|
|
|
} onCommit: {
|
2021-10-19 04:48:37 +00:00
|
|
|
speechForwarder.validate(destination: speechForwarder.ipAddress)
|
2021-07-17 03:12:01 +00:00
|
|
|
}
|
|
|
|
.padding()
|
2021-07-17 03:20:52 +00:00
|
|
|
|
2021-07-20 23:42:47 +00:00
|
|
|
ScrollView() {
|
2021-10-19 04:48:37 +00:00
|
|
|
Text(speechForwarder.log)
|
2021-07-20 23:42:47 +00:00
|
|
|
.multilineTextAlignment(.leading)
|
|
|
|
}
|
2021-07-17 03:20:52 +00:00
|
|
|
|
2021-07-17 02:58:41 +00:00
|
|
|
Button("Listen") {
|
2021-10-19 04:48:37 +00:00
|
|
|
speechForwarder.listen()
|
2021-07-17 02:58:41 +00:00
|
|
|
}
|
2021-07-17 03:20:52 +00:00
|
|
|
.padding()
|
2021-10-19 04:48:37 +00:00
|
|
|
.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-17 02:58:41 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-16 16:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct ContentView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
ContentView()
|
|
|
|
}
|
|
|
|
}
|