From 9a17b65abe2df29e37e59b077401daff5fe02cf8 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 13 Sep 2022 09:56:03 -0700 Subject: [PATCH] Clean up node list and details views --- Meshtastic/Helpers/BLEManager.swift | 6 +-- Meshtastic/Views/Nodes/LocationHistory.swift | 4 +- Meshtastic/Views/Nodes/NodeDetail.swift | 40 ++++++++++---------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 75e4aa07..b8009945 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -114,7 +114,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph if centralManager.isScanning { self.centralManager.stopScan() - // self.isScanning = self.centralManager.isScanning + isScanning = self.centralManager.isScanning print("🛑 Stopped Scanning") } } @@ -170,7 +170,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph self.disconnectPeripheral() } - //self.connectedVersion = "0.0.0" + self.connectedVersion = "0.0.0" self.centralManager?.connect(peripheral) // Invalidate any existing timer @@ -223,7 +223,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph } let today = Date() - let visibleDuration = Calendar.current.date(byAdding: .second, value: -4, to: today)! + let visibleDuration = Calendar.current.date(byAdding: .second, value: -2, to: today)! peripherals.removeAll(where: { $0.lastUpdate <= visibleDuration}) } diff --git a/Meshtastic/Views/Nodes/LocationHistory.swift b/Meshtastic/Views/Nodes/LocationHistory.swift index 52165e2d..ad4299e2 100644 --- a/Meshtastic/Views/Nodes/LocationHistory.swift +++ b/Meshtastic/Views/Nodes/LocationHistory.swift @@ -18,8 +18,8 @@ struct LocationHistory: View { var body: some View { - VStack { - + NavigationStack { + List { ForEach(node.positions!.reversed() as! [PositionEntity], id: \.self) { (mappin: PositionEntity) in diff --git a/Meshtastic/Views/Nodes/NodeDetail.swift b/Meshtastic/Views/Nodes/NodeDetail.swift index 9754c36b..7a91e6fe 100644 --- a/Meshtastic/Views/Nodes/NodeDetail.swift +++ b/Meshtastic/Views/Nodes/NodeDetail.swift @@ -63,8 +63,8 @@ struct NodeDetail: View { } ) } - .ignoresSafeArea(.all, edges: [.leading, .trailing]) - .frame(idealWidth: bounds.size.width, minHeight: bounds.size.height / 2) + .ignoresSafeArea(.all, edges: [.leading, .trailing]) + .frame(idealWidth: bounds.size.width, minHeight: bounds.size.height / 1.70) } } Text("Sats: \(mostRecent.satsInView)").offset( y:-40) @@ -440,28 +440,30 @@ struct NodeDetail: View { } } .offset( y:-40) + .padding(.bottom, -40) } .edgesIgnoringSafeArea([.leading, .trailing]) - } - } - .navigationTitle((node.user != nil) ? String(node.user!.longName ?? "Unknown") : "Unknown") - .navigationBarTitleDisplayMode(.inline) - .navigationBarItems(trailing: + .navigationTitle((node.user != nil) ? String(node.user!.longName ?? "Unknown") : "Unknown") + .navigationBarTitleDisplayMode(.inline) + .padding(.bottom, 10) + .navigationBarItems(trailing: - ZStack { + ZStack { - ConnectedDevice( - bluetoothOn: bleManager.isSwitchedOn, - deviceConnected: bleManager.connectedPeripheral != nil, - name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "????") - } - ) - .onAppear { + ConnectedDevice( + bluetoothOn: bleManager.isSwitchedOn, + deviceConnected: bleManager.connectedPeripheral != nil, + name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "????") + } + ) + .onAppear { - if self.initialLoad{ - - self.bleManager.context = context - self.initialLoad = false + if self.initialLoad{ + + self.bleManager.context = context + self.initialLoad = false + } + } } } }