mirror of
https://github.com/jeremysrand/ListenerApp.git
synced 2024-06-06 09:29:29 +00:00
Move the destination data model stuff out of the UI.
This commit is contained in:
parent
2c58886439
commit
0528a7db41
|
@ -110,7 +110,6 @@
|
||||||
9D5155E626A1EF7B0075EBC7 = {
|
9D5155E626A1EF7B0075EBC7 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
9DD67CEF2728F5B700243FC6 /* DestinationsView.swift */,
|
|
||||||
9D51562126A1F0DF0075EBC7 /* LICENSE */,
|
9D51562126A1F0DF0075EBC7 /* LICENSE */,
|
||||||
9D51562A26A1F1B40075EBC7 /* README.md */,
|
9D51562A26A1F1B40075EBC7 /* README.md */,
|
||||||
9D5155F126A1EF7B0075EBC7 /* ListenerGS */,
|
9D5155F126A1EF7B0075EBC7 /* ListenerGS */,
|
||||||
|
@ -137,6 +136,7 @@
|
||||||
9D0DC15826F2E47A007EB92D /* ListenerGS.entitlements */,
|
9D0DC15826F2E47A007EB92D /* ListenerGS.entitlements */,
|
||||||
9D5155F226A1EF7B0075EBC7 /* ListenerGSApp.swift */,
|
9D5155F226A1EF7B0075EBC7 /* ListenerGSApp.swift */,
|
||||||
9D6F27082728EF410089585E /* MainView.swift */,
|
9D6F27082728EF410089585E /* MainView.swift */,
|
||||||
|
9DD67CEF2728F5B700243FC6 /* DestinationsView.swift */,
|
||||||
9DCCDACB271FB87100F311DF /* GSDestinations.swift */,
|
9DCCDACB271FB87100F311DF /* GSDestinations.swift */,
|
||||||
9D5155F426A1EF7B0075EBC7 /* ContentView.swift */,
|
9D5155F426A1EF7B0075EBC7 /* ContentView.swift */,
|
||||||
9D6ED239271E6BD600D773CD /* SpeechForwarder.swift */,
|
9D6ED239271E6BD600D773CD /* SpeechForwarder.swift */,
|
||||||
|
|
|
@ -7,20 +7,17 @@
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct Destination: Identifiable, Hashable {
|
|
||||||
let ipAddress : String
|
|
||||||
let id = UUID()
|
|
||||||
}
|
|
||||||
|
|
||||||
struct DestinationsView: View {
|
struct DestinationsView: View {
|
||||||
@State private var destinations:[Destination] = []
|
|
||||||
@State private var editMode = EditMode.inactive
|
@State private var editMode = EditMode.inactive
|
||||||
@State private var showPopover = false
|
@State private var showPopover = false
|
||||||
@State private var newDestination = ""
|
@State private var newDestination = ""
|
||||||
|
|
||||||
|
@StateObject private var destinations = GSDestinations()
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
ForEach(destinations) { destination in
|
ForEach(destinations.dests) { destination in
|
||||||
NavigationLink(destination: Text(destination.ipAddress)) {
|
NavigationLink(destination: Text(destination.ipAddress)) {
|
||||||
Text(destination.ipAddress)
|
Text(destination.ipAddress)
|
||||||
}
|
}
|
||||||
|
@ -70,11 +67,11 @@ struct DestinationsView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func onDelete(offsets: IndexSet) {
|
private func onDelete(offsets: IndexSet) {
|
||||||
destinations.remove(atOffsets: offsets)
|
destinations.onDelete(offsets: offsets)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func onMove(source: IndexSet, destination: Int) {
|
private func onMove(source: IndexSet, destination: Int) {
|
||||||
destinations.move(fromOffsets: source, toOffset: destination)
|
destinations.onMove(source: source, destination: destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
func showAdd() {
|
func showAdd() {
|
||||||
|
@ -82,7 +79,7 @@ struct DestinationsView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
func onAdd() {
|
func onAdd() {
|
||||||
destinations.append(Destination(ipAddress: self.newDestination))
|
destinations.onAdd(ipAddress: self.newDestination)
|
||||||
newDestination = ""
|
newDestination = ""
|
||||||
showPopover = false;
|
showPopover = false;
|
||||||
}
|
}
|
|
@ -7,5 +7,24 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
class GSDestinations : ObservableObject {
|
|
||||||
|
struct Destination: Identifiable, Hashable {
|
||||||
|
let ipAddress : String
|
||||||
|
let id = UUID()
|
||||||
|
}
|
||||||
|
|
||||||
|
class GSDestinations : ObservableObject {
|
||||||
|
@Published var dests:[Destination] = []
|
||||||
|
|
||||||
|
public func onDelete(offsets: IndexSet) {
|
||||||
|
dests.remove(atOffsets: offsets)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func onMove(source: IndexSet, destination: Int) {
|
||||||
|
dests.move(fromOffsets: source, toOffset: destination)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func onAdd(ipAddress: String) {
|
||||||
|
dests.append(Destination(ipAddress: ipAddress))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0</string>
|
<string>1.0</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>239</string>
|
<string>242</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.utilities</string>
|
<string>public.app-category.utilities</string>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user