Lots of UI changes towards allowing the user to add multiple destinations, sync them with iCloud and a better UI in general on all platforms. Not all hooked up yet though.

This commit is contained in:
Jeremy Rand 2021-10-26 23:19:22 -04:00
parent 81e0925f6f
commit 3b2d4beb55
8 changed files with 122 additions and 2 deletions

63
DestinationsView.swift Normal file
View File

@ -0,0 +1,63 @@
//
// DestinationsView.swift
// ListenerGS
//
// Created by Jeremy Rand on 2021-10-26.
//
import SwiftUI
struct Destination: Identifiable, Hashable {
let ipAddress : String
let id = UUID()
}
struct DestinationsView: View {
@State private var destinations = [
Destination(ipAddress: "192.168.1.20"),
Destination(ipAddress: "192.168.1.21")
]
@State private var editMode = EditMode.inactive
var body: some View {
List {
ForEach(destinations) { destination in
NavigationLink(destination: Text(destination.ipAddress)) {
Text(destination.ipAddress)
}
}
.onDelete(perform: onDelete)
.onMove(perform: onMove)
}
.navigationBarTitle("GS Destinations")
.navigationBarItems(leading: EditButton(), trailing: addButton)
.environment(\.editMode, $editMode)
}
private var addButton: some View {
switch editMode {
case .inactive:
return AnyView(Button(action: onAdd) { Image(systemName: "plus") })
default:
return AnyView(EmptyView())
}
}
private func onDelete(offsets: IndexSet) {
destinations.remove(atOffsets: offsets)
}
private func onMove(source: IndexSet, destination: Int) {
destinations.move(fromOffsets: source, toOffset: destination)
}
func onAdd() {
destinations.append(Destination(ipAddress: "192.168.1.22"))
}
}
struct DestinationsView_Previews: PreviewProvider {
static var previews: some View {
DestinationsView()
}
}

View File

@ -25,6 +25,9 @@
9D51567326A36FEC0075EBC7 /* BinUtils.LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 9D51567226A36FEC0075EBC7 /* BinUtils.LICENSE */; };
9D51567E26A370380075EBC7 /* SwiftSocket.LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 9D51567D26A370380075EBC7 /* SwiftSocket.LICENSE */; };
9D6ED23A271E6BD600D773CD /* SpeechForwarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D6ED239271E6BD600D773CD /* SpeechForwarder.swift */; };
9D6F27092728EF410089585E /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D6F27082728EF410089585E /* MainView.swift */; };
9DCCDACC271FB87100F311DF /* GSDestinations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DCCDACB271FB87100F311DF /* GSDestinations.swift */; };
9DD67CF02728F5B700243FC6 /* DestinationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD67CEF2728F5B700243FC6 /* DestinationsView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -73,6 +76,9 @@
9D51567226A36FEC0075EBC7 /* BinUtils.LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = BinUtils.LICENSE; sourceTree = "<group>"; };
9D51567D26A370380075EBC7 /* SwiftSocket.LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SwiftSocket.LICENSE; sourceTree = "<group>"; };
9D6ED239271E6BD600D773CD /* SpeechForwarder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpeechForwarder.swift; sourceTree = "<group>"; };
9D6F27082728EF410089585E /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
9DCCDACB271FB87100F311DF /* GSDestinations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GSDestinations.swift; sourceTree = "<group>"; };
9DD67CEF2728F5B700243FC6 /* DestinationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DestinationsView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -104,6 +110,7 @@
9D5155E626A1EF7B0075EBC7 = {
isa = PBXGroup;
children = (
9DD67CEF2728F5B700243FC6 /* DestinationsView.swift */,
9D51562126A1F0DF0075EBC7 /* LICENSE */,
9D51562A26A1F1B40075EBC7 /* README.md */,
9D5155F126A1EF7B0075EBC7 /* ListenerGS */,
@ -129,6 +136,8 @@
children = (
9D0DC15826F2E47A007EB92D /* ListenerGS.entitlements */,
9D5155F226A1EF7B0075EBC7 /* ListenerGSApp.swift */,
9D6F27082728EF410089585E /* MainView.swift */,
9DCCDACB271FB87100F311DF /* GSDestinations.swift */,
9D5155F426A1EF7B0075EBC7 /* ContentView.swift */,
9D6ED239271E6BD600D773CD /* SpeechForwarder.swift */,
9D51566326A36F530075EBC7 /* BinUtils */,
@ -354,7 +363,9 @@
buildActionMask = 2147483647;
files = (
9D51565726A36B410075EBC7 /* TCPClient.swift in Sources */,
9D6F27092728EF410089585E /* MainView.swift in Sources */,
9D51565526A36B410075EBC7 /* UDPClient.swift in Sources */,
9DD67CF02728F5B700243FC6 /* DestinationsView.swift in Sources */,
9D51565626A36B410075EBC7 /* Socket.swift in Sources */,
9D51565326A36B410075EBC7 /* yudpsocket.c in Sources */,
9D51565226A36B410075EBC7 /* Result.swift in Sources */,
@ -362,6 +373,7 @@
9D6ED23A271E6BD600D773CD /* SpeechForwarder.swift in Sources */,
9D5155F326A1EF7B0075EBC7 /* ListenerGSApp.swift in Sources */,
9D51566526A36F6D0075EBC7 /* BinUtils.swift in Sources */,
9DCCDACC271FB87100F311DF /* GSDestinations.swift in Sources */,
9D51565426A36B410075EBC7 /* ytcpsocket.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;

View File

@ -10,6 +10,7 @@ import Speech
struct ContentView: View {
@StateObject private var speechForwarder = SpeechForwarder()
// private var destinations: GSDestinations
var body: some View {
VStack {

View File

@ -0,0 +1,11 @@
//
// GSDestinations.swift
// ListenerGS
//
// Created by Jeremy Rand on 2021-10-19.
//
import Foundation
class GSDestinations : ObservableObject {
}

View File

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>132</string>
<string>188</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSRequiresIPhoneOS</key>

View File

@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.icloud-container-identifiers</key>
<array/>
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.device.audio-input</key>

View File

@ -9,9 +9,13 @@ import SwiftUI
@main
struct ListenerGSApp: App {
@StateObject private var destinations = GSDestinations()
var body: some Scene {
WindowGroup {
ContentView()
// ContentView(destinations: destinations)
// ContentView()
MainView()
}
}
}

25
ListenerGS/MainView.swift Normal file
View File

@ -0,0 +1,25 @@
//
// MainView.swift
// ListenerGS
//
// Created by Jeremy Rand on 2021-10-26.
//
import SwiftUI
struct MainView: View {
var body: some View {
NavigationView {
DestinationsView()
EmptyView() // JSR_TODO - Maybe display some instructions here.
}
}
}
struct MainView_Previews: PreviewProvider {
static var previews: some View {
Group {
MainView()
}
}
}