From a2a4c65c30226c284af690f65a8d8d9b94b6944c Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 10 Sep 2023 18:50:11 -0700 Subject: [PATCH] Cleanup --- Meshtastic.xcodeproj/project.pbxproj | 4 - .../Views/Nodes/DetectionSensorLog.swift | 4 +- Meshtastic/Views/Nodes/DeviceMetricsLog.swift | 4 +- .../Views/Nodes/EnvironmentMetricsLog.swift | 4 +- .../Views/Nodes/Helpers/NodeDetail.swift | 4 +- Meshtastic/Views/Nodes/NodeListOld.swift | 136 ------------------ Meshtastic/Views/Nodes/NodeMap.swift | 4 +- 7 files changed, 14 insertions(+), 146 deletions(-) delete mode 100644 Meshtastic/Views/Nodes/NodeListOld.swift diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 2049f791..d1eb78ab 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -37,7 +37,6 @@ DD41582A28585C32009B0E59 /* RangeTestConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD41582928585C32009B0E59 /* RangeTestConfig.swift */; }; DD41A61529AB0035003C5A37 /* NodeWeatherForecast.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD41A61429AB0035003C5A37 /* NodeWeatherForecast.swift */; }; DD457188293C7E63000C49FB /* BLESignalStrengthIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD457187293C7E63000C49FB /* BLESignalStrengthIndicator.swift */; }; - DD47E3CE26F103C600029299 /* NodeListOld.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD47E3CD26F103C600029299 /* NodeListOld.swift */; }; DD47E3D626F17ED900029299 /* CircleText.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD47E3D526F17ED900029299 /* CircleText.swift */; }; DD4A911E2708C65400501B7E /* AppSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD4A911D2708C65400501B7E /* AppSettings.swift */; }; DD4F23CD28779A3C001D37CB /* EnvironmentMetricsLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD4F23CC28779A3C001D37CB /* EnvironmentMetricsLog.swift */; }; @@ -241,7 +240,6 @@ DD41A61E29AE7E8F003C5A37 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; DD457187293C7E63000C49FB /* BLESignalStrengthIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BLESignalStrengthIndicator.swift; sourceTree = ""; }; DD457BC4295D5E35004BCE4D /* MeshtasticDataModelV5.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV5.xcdatamodel; sourceTree = ""; }; - DD47E3CD26F103C600029299 /* NodeListOld.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeListOld.swift; sourceTree = ""; }; DD47E3D526F17ED900029299 /* CircleText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleText.swift; sourceTree = ""; }; DD4A911D2708C65400501B7E /* AppSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSettings.swift; sourceTree = ""; }; DD4F23CC28779A3C001D37CB /* EnvironmentMetricsLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnvironmentMetricsLog.swift; sourceTree = ""; }; @@ -473,7 +471,6 @@ DD4F23CC28779A3C001D37CB /* EnvironmentMetricsLog.swift */, 6DEDA5592A957B8E00321D2E /* DetectionSensorLog.swift */, DD2E65252767A01F00E45FC5 /* NodeDetailOld.swift */, - DD47E3CD26F103C600029299 /* NodeListOld.swift */, ); path = Nodes; sourceTree = ""; @@ -1125,7 +1122,6 @@ DD5E520D298EE33B00D21B61 /* storeforward.pb.swift in Sources */, DD964FC2297272AE007C176F /* WaypointEntityExtension.swift in Sources */, 6DA39D8E2A92DC52007E311C /* MeshtasticAppDelegate.swift in Sources */, - DD47E3CE26F103C600029299 /* NodeListOld.swift in Sources */, DD5E520A298EE33B00D21B61 /* channel.pb.swift in Sources */, DD8EBF43285058FA00426DCA /* DisplayConfig.swift in Sources */, DD964FC42974767D007C176F /* MapViewFitExtension.swift in Sources */, diff --git a/Meshtastic/Views/Nodes/DetectionSensorLog.swift b/Meshtastic/Views/Nodes/DetectionSensorLog.swift index c3604ab8..6d2551cd 100644 --- a/Meshtastic/Views/Nodes/DetectionSensorLog.swift +++ b/Meshtastic/Views/Nodes/DetectionSensorLog.swift @@ -124,7 +124,9 @@ struct DetectionSensorLog: View { ConnectedDevice(bluetoothOn: bleManager.isSwitchedOn, deviceConnected: bleManager.connectedPeripheral != nil, name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?") }) .onAppear { - self.bleManager.context = context + if self.bleManager.context == nil { + self.bleManager.context = context + } } .fileExporter( isPresented: $isExporting, diff --git a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift index 08cd55c6..232e1b8f 100644 --- a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift +++ b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift @@ -211,7 +211,9 @@ struct DeviceMetricsLog: View { ConnectedDevice(bluetoothOn: bleManager.isSwitchedOn, deviceConnected: bleManager.connectedPeripheral != nil, name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?") }) .onAppear { - self.bleManager.context = context + if self.bleManager.context == nil { + self.bleManager.context = context + } } .fileExporter( isPresented: $isExporting, diff --git a/Meshtastic/Views/Nodes/EnvironmentMetricsLog.swift b/Meshtastic/Views/Nodes/EnvironmentMetricsLog.swift index ccc0ccdb..f402be8a 100644 --- a/Meshtastic/Views/Nodes/EnvironmentMetricsLog.swift +++ b/Meshtastic/Views/Nodes/EnvironmentMetricsLog.swift @@ -193,7 +193,9 @@ struct EnvironmentMetricsLog: View { ConnectedDevice(bluetoothOn: bleManager.isSwitchedOn, deviceConnected: bleManager.connectedPeripheral != nil, name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?") }) .onAppear { - self.bleManager.context = context + if self.bleManager.context == nil { + self.bleManager.context = context + } } .fileExporter( isPresented: $isExporting, diff --git a/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift b/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift index 1dd43ba4..3ee69c79 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift @@ -22,7 +22,7 @@ struct NodeDetail: View { var body: some View { let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral?.num ?? -1, context: context) -// NavigationStack { + NavigationStack { GeometryReader { bounds in VStack { ScrollView { @@ -147,6 +147,6 @@ struct NodeDetail: View { } } .padding(.bottom, 2) -// } + } } } diff --git a/Meshtastic/Views/Nodes/NodeListOld.swift b/Meshtastic/Views/Nodes/NodeListOld.swift deleted file mode 100644 index c47b1909..00000000 --- a/Meshtastic/Views/Nodes/NodeListOld.swift +++ /dev/null @@ -1,136 +0,0 @@ -//// -//// NodeList.swift -//// Meshtastic -//// -//// Copyright(c) Garth Vander Houwen 8/7/21. -//// -// -//// Abstract: -//// A view showing a list of devices that have been seen on the mesh network from the perspective of the connected device. -// -//import SwiftUI -//import CoreLocation -// -//struct NodeList: View { -// -// @State private var searchText = "" -// var nodesQuery: Binding { -// Binding { -// searchText -// } set: { newValue in -// searchText = newValue -// nodes.nsPredicate = newValue.isEmpty ? nil : NSPredicate(format: "user.longName CONTAINS[c] %@ OR user.shortName CONTAINS[c] %@", newValue, newValue) -// } -// } -// -// @Environment(\.managedObjectContext) var context -// @EnvironmentObject var bleManager: BLEManager -// -// @FetchRequest( -// sortDescriptors: [NSSortDescriptor(key: "lastHeard", ascending: false)], -// animation: .default) -// -// private var nodes: FetchedResults -// -// @State private var selection: NodeInfoEntity? // Nothing selected by default. -// -// var body: some View { -// -// NavigationSplitView { -// let connectedNodeNum = Int(bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral?.num ?? 0 : 0) -// let connectedNode = nodes.first(where: { $0.num == connectedNodeNum }) -// List(nodes, id: \.self, selection: $selection) { node in -// if nodes.count == 0 { -// Text("no.nodes").font(.title) -// } else { -// NavigationLink(value: node) { -// let connected: Bool = (bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral?.num ?? -1 == node.num) -// LazyVStack(alignment: .leading) { -// HStack { -// VStack(alignment: .leading) { -// CircleText(text: node.user?.shortName ?? "?", color: Color(UIColor(hex: UInt32(node.num))), circleSize: 65) -// .padding(.trailing, 5) -// let deviceMetrics = node.telemetries?.filtered(using: NSPredicate(format: "metricsType == 0")) -// if deviceMetrics?.count ?? 0 >= 1 { -// let mostRecent = deviceMetrics?.lastObject as? TelemetryEntity -// BatteryLevelCompact(batteryLevel: mostRecent?.batteryLevel, font: .caption2, iconFont: .callout, color: .accentColor) -// } -// } -// VStack(alignment: .leading) { -// Text(node.user?.longName ?? "unknown".localized) -// .fontWeight(.medium) -// .font(.callout) -// if connected { -// HStack(alignment: .bottom) { -// Image(systemName: "antenna.radiowaves.left.and.right.circle.fill") -// .font(.footnote) -// .symbolRenderingMode(.hierarchical) -// .foregroundColor(.green) -// Text("connected").font(.caption) -// } -// } -// HStack(alignment: .bottom) { -// Image(systemName: node.isOnline ? "checkmark.circle.fill" : "moon.circle.fill") -// .font(.footnote) -// .symbolRenderingMode(.hierarchical) -// .foregroundColor(node.isOnline ? .green : .orange) -// LastHeardText(lastHeard: node.lastHeard) -// .font(.caption) -// } -// if node.positions?.count ?? 0 > 0 && (bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral?.num ?? -1 != node.num) { -// HStack(alignment: .bottom) { -// let lastPostion = node.positions!.reversed()[0] as! PositionEntity -// let myCoord = CLLocation(latitude: LocationHelper.currentLocation.latitude, longitude: LocationHelper.currentLocation.longitude) -// if lastPostion.nodeCoordinate != nil && myCoord.coordinate.longitude != LocationHelper.DefaultLocation.longitude && myCoord.coordinate.latitude != LocationHelper.DefaultLocation.latitude { -// let nodeCoord = CLLocation(latitude: lastPostion.nodeCoordinate!.latitude, longitude: lastPostion.nodeCoordinate!.longitude) -// let metersAway = nodeCoord.distance(from: myCoord) -// Image(systemName: "lines.measurement.horizontal") -// .font(.footnote) -// .symbolRenderingMode(.hierarchical) -// DistanceText(meters: metersAway).font(.caption) -// } -// } -// } -// if node.channel > 0 { -// HStack(alignment: .bottom) { -// Image(systemName: "fibrechannel") -// .font(.footnote) -// .symbolRenderingMode(.hierarchical) -// Text("Channel: \(node.channel)") -// .font(.footnote) -// } -// } -// if !connected { -// HStack(alignment: .bottom) { let preset = ModemPresets(rawValue: Int(connectedNode?.loRaConfig?.modemPreset ?? 0)) -// LoRaSignalStrengthMeter(snr: node.snr, rssi: node.rssi, preset: preset ?? ModemPresets.longFast, compact: true) -// } -// } -// } -// .frame(maxWidth: .infinity, alignment: .leading) -// } -// } -// } -// .padding([.top, .bottom]) -// } -// } -// .listStyle(.plain) -// .navigationSplitViewColumnWidth(300) -// .navigationTitle(String.localizedStringWithFormat("nodes %@".localized, String(nodes.count))) -// .navigationBarItems(leading: -// MeshtasticLogo() -// ) -// .onAppear { -// if self.bleManager.context == nil { -// self.bleManager.context = context -// } -// } -// } detail: { -// if let node = selection { -// NodeDetail(node: node) -// } else { -// Text("select.node") -// } -// } -// .searchable(text: nodesQuery, prompt: "Find a node") -// } -//} diff --git a/Meshtastic/Views/Nodes/NodeMap.swift b/Meshtastic/Views/Nodes/NodeMap.swift index e6edd97a..a41f891c 100644 --- a/Meshtastic/Views/Nodes/NodeMap.swift +++ b/Meshtastic/Views/Nodes/NodeMap.swift @@ -238,7 +238,9 @@ struct NodeMap: View { }) .onAppear(perform: { UIApplication.shared.isIdleTimerDisabled = true - self.bleManager.context = context + if self.bleManager.context == nil { + self.bleManager.context = context + } }) .onDisappear(perform: { UIApplication.shared.isIdleTimerDisabled = false