mirror of
https://github.com/jeremysrand/ListenerApp.git
synced 2024-12-13 05:29:09 +00:00
Put uuids in the iCloud data about each destination and start building the view for a specific destination to control the connection, listening and debug.
This commit is contained in:
parent
ab4ea0ca5d
commit
abab6bb844
@ -28,6 +28,7 @@
|
||||
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 */; };
|
||||
9DD890602772D3B20084A894 /* GSView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD8905F2772D3B20084A894 /* GSView.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@ -80,6 +81,7 @@
|
||||
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>"; };
|
||||
9DD8905E27726C140084A894 /* ListenerGS Icon.pxm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "ListenerGS Icon.pxm"; sourceTree = "<group>"; };
|
||||
9DD8905F2772D3B20084A894 /* GSView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GSView.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -139,6 +141,7 @@
|
||||
9D6F27082728EF410089585E /* MainView.swift */,
|
||||
9DD67CEF2728F5B700243FC6 /* DestinationsView.swift */,
|
||||
9DCCDACB271FB87100F311DF /* GSDestinations.swift */,
|
||||
9DD8905F2772D3B20084A894 /* GSView.swift */,
|
||||
9D5155F426A1EF7B0075EBC7 /* ContentView.swift */,
|
||||
9D6ED239271E6BD600D773CD /* SpeechForwarder.swift */,
|
||||
9DD8905E27726C140084A894 /* ListenerGS Icon.pxm */,
|
||||
@ -370,6 +373,7 @@
|
||||
9DD67CF02728F5B700243FC6 /* DestinationsView.swift in Sources */,
|
||||
9D51565626A36B410075EBC7 /* Socket.swift in Sources */,
|
||||
9D51565326A36B410075EBC7 /* yudpsocket.c in Sources */,
|
||||
9DD890602772D3B20084A894 /* GSView.swift in Sources */,
|
||||
9D51565226A36B410075EBC7 /* Result.swift in Sources */,
|
||||
9D5155F526A1EF7B0075EBC7 /* ContentView.swift in Sources */,
|
||||
9D6ED23A271E6BD600D773CD /* SpeechForwarder.swift in Sources */,
|
||||
|
@ -18,7 +18,7 @@ struct DestinationsView: View {
|
||||
var body: some View {
|
||||
List {
|
||||
ForEach(destinations.dests) { destination in
|
||||
NavigationLink(destination: Text(destination.ipAddress)) {
|
||||
NavigationLink(destination: GSView(ipAddress: destination.ipAddress)) {
|
||||
Text(destination.ipAddress)
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,24 @@ import Foundation
|
||||
|
||||
struct Destination: Identifiable, Hashable {
|
||||
let ipAddress : String
|
||||
let id = UUID()
|
||||
let id : UUID
|
||||
|
||||
init(ipAddress: String)
|
||||
{
|
||||
self.ipAddress = ipAddress
|
||||
self.id = UUID()
|
||||
}
|
||||
|
||||
init(ipAddress: String, uuid: String)
|
||||
{
|
||||
self.ipAddress = ipAddress
|
||||
let idMaybe = UUID(uuidString: uuid)
|
||||
if let id = idMaybe {
|
||||
self.id = id
|
||||
} else {
|
||||
self.id = UUID()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GSDestinations : ObservableObject {
|
||||
@ -20,6 +37,7 @@ class GSDestinations : ObservableObject {
|
||||
|
||||
static let kDestinationKey = "destinations"
|
||||
static let kDestinationIpAddress = "ip_address"
|
||||
static let kDestinationUUID = "uuid"
|
||||
|
||||
public func onDelete(offsets: IndexSet) {
|
||||
dests.remove(atOffsets: offsets)
|
||||
@ -34,8 +52,9 @@ class GSDestinations : ObservableObject {
|
||||
}
|
||||
|
||||
public func onAdd(ipAddress: String) {
|
||||
dests.append(Destination(ipAddress: ipAddress))
|
||||
storedDestinations.append([GSDestinations.kDestinationIpAddress : ipAddress])
|
||||
let newDestination = Destination(ipAddress: ipAddress)
|
||||
dests.append(newDestination)
|
||||
storedDestinations.append([GSDestinations.kDestinationIpAddress : ipAddress, GSDestinations.kDestinationUUID : newDestination.id.uuidString])
|
||||
saveDestinations()
|
||||
}
|
||||
|
||||
@ -46,7 +65,11 @@ class GSDestinations : ObservableObject {
|
||||
|
||||
for value in storedDestinations {
|
||||
if let ipAddress = (value as! [String:String])[GSDestinations.kDestinationIpAddress] {
|
||||
dests.append(Destination(ipAddress: ipAddress))
|
||||
if let id = (value as! [String:String])[GSDestinations.kDestinationUUID] {
|
||||
dests.append(Destination(ipAddress: ipAddress, uuid: id))
|
||||
} else {
|
||||
dests.append(Destination(ipAddress: ipAddress))
|
||||
}
|
||||
} else {
|
||||
storedDestinations = []
|
||||
dests = []
|
||||
|
33
ListenerGS/GSView.swift
Normal file
33
ListenerGS/GSView.swift
Normal file
@ -0,0 +1,33 @@
|
||||
//
|
||||
// GSView.swift
|
||||
// ListenerGS
|
||||
//
|
||||
// Created by Jeremy Rand on 2021-12-21.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct GSView: View {
|
||||
private let ipAddress : String
|
||||
|
||||
var body: some View {
|
||||
Text(ipAddress)
|
||||
Button("Connect to \(ipAddress)") {
|
||||
|
||||
}
|
||||
.padding()
|
||||
.background(Color(red: 0, green: 0, blue: 0.5))
|
||||
.foregroundColor(.white)
|
||||
.clipShape(Capsule())
|
||||
}
|
||||
|
||||
init(ipAddress : String) {
|
||||
self.ipAddress = ipAddress
|
||||
}
|
||||
}
|
||||
|
||||
struct GSView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
GSView(ipAddress: "192.168.1.1")
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>249</string>
|
||||
<string>278</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
Loading…
Reference in New Issue
Block a user