diff --git a/DestinationsView.swift b/DestinationsView.swift new file mode 100644 index 0000000..15548a2 --- /dev/null +++ b/DestinationsView.swift @@ -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() + } +} diff --git a/ListenerGS.xcodeproj/project.pbxproj b/ListenerGS.xcodeproj/project.pbxproj index 340bef2..1cca1e0 100644 --- a/ListenerGS.xcodeproj/project.pbxproj +++ b/ListenerGS.xcodeproj/project.pbxproj @@ -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 = ""; }; 9D51567D26A370380075EBC7 /* SwiftSocket.LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SwiftSocket.LICENSE; sourceTree = ""; }; 9D6ED239271E6BD600D773CD /* SpeechForwarder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpeechForwarder.swift; sourceTree = ""; }; + 9D6F27082728EF410089585E /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = ""; }; + 9DCCDACB271FB87100F311DF /* GSDestinations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GSDestinations.swift; sourceTree = ""; }; + 9DD67CEF2728F5B700243FC6 /* DestinationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DestinationsView.swift; sourceTree = ""; }; /* 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; diff --git a/ListenerGS/ContentView.swift b/ListenerGS/ContentView.swift index 9f2b397..2e6a6ee 100644 --- a/ListenerGS/ContentView.swift +++ b/ListenerGS/ContentView.swift @@ -10,6 +10,7 @@ import Speech struct ContentView: View { @StateObject private var speechForwarder = SpeechForwarder() + // private var destinations: GSDestinations var body: some View { VStack { diff --git a/ListenerGS/GSDestinations.swift b/ListenerGS/GSDestinations.swift new file mode 100644 index 0000000..8ceaa9c --- /dev/null +++ b/ListenerGS/GSDestinations.swift @@ -0,0 +1,11 @@ +// +// GSDestinations.swift +// ListenerGS +// +// Created by Jeremy Rand on 2021-10-19. +// + +import Foundation + +class GSDestinations : ObservableObject { +} diff --git a/ListenerGS/Info.plist b/ListenerGS/Info.plist index 32907fe..310597b 100644 --- a/ListenerGS/Info.plist +++ b/ListenerGS/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 1.0 CFBundleVersion - 132 + 188 LSApplicationCategoryType public.app-category.utilities LSRequiresIPhoneOS diff --git a/ListenerGS/ListenerGS.entitlements b/ListenerGS/ListenerGS.entitlements index afafa97..fb11d34 100644 --- a/ListenerGS/ListenerGS.entitlements +++ b/ListenerGS/ListenerGS.entitlements @@ -2,6 +2,10 @@ + com.apple.developer.icloud-container-identifiers + + com.apple.developer.ubiquity-kvstore-identifier + $(TeamIdentifierPrefix)$(CFBundleIdentifier) com.apple.security.app-sandbox com.apple.security.device.audio-input diff --git a/ListenerGS/ListenerGSApp.swift b/ListenerGS/ListenerGSApp.swift index afd368c..3f116ba 100644 --- a/ListenerGS/ListenerGSApp.swift +++ b/ListenerGS/ListenerGSApp.swift @@ -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() } } } diff --git a/ListenerGS/MainView.swift b/ListenerGS/MainView.swift new file mode 100644 index 0000000..0c11547 --- /dev/null +++ b/ListenerGS/MainView.swift @@ -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() + } + } +}