From def589113b3ee8addba54e6b6288c172151f52bd Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 17 Oct 2022 21:32:14 -0700 Subject: [PATCH] Clean up node list --- Meshtastic/Views/Nodes/NodeList.swift | 47 ++------------------------- 1 file changed, 3 insertions(+), 44 deletions(-) diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 80a6c76a..1c1758dc 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -16,8 +16,6 @@ struct NodeList: View { @Environment(\.managedObjectContext) var context @EnvironmentObject var bleManager: BLEManager @EnvironmentObject var userSettings: UserSettings - - @State var initialLoad: Bool = true @FetchRequest( sortDescriptors: [NSSortDescriptor(key: "lastHeard", ascending: false)], @@ -30,11 +28,8 @@ struct NodeList: View { var body: some View { NavigationSplitView { - List (nodes, id: \.self, selection: $selection) { node in - if nodes.count == 0 { - Text("Scan for Radios").font(.largeTitle) Text("No Meshtastic Nodes Found").font(.title2) Text("Go to the bluetooth section in the bottom right menu and click the Start Scanning button to scan for nearby radios and find your Meshtastic device. Make sure your device is powered on and near your iPhone, iPad or Mac.") @@ -42,20 +37,13 @@ struct NodeList: View { Text("Once the device shows under Available Devices touch the device you want to connect to and it will pull node information over BLE and populate the node list and mesh map in the Meshtastic app.") Text("Views with bluetooth functionality will show an indicator in the upper right hand corner showing if bluetooth is on, and if a device is connected.") .listRowSeparator(.visible) - } else { - NavigationLink(value: node) { - let connected: Bool = (bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral.num == node.num) - VStack(alignment: .leading) { - HStack { - CircleText(text: node.user?.shortName ?? "???", color: .blue).offset(y: 1).padding(.trailing, 5) .offset(x: -15) - if UIDevice.current.userInterfaceIdiom == .pad { Text(node.user?.longName ?? "Unknown").font(.headline) .offset(x: -15) } else { @@ -63,58 +51,39 @@ struct NodeList: View { } } .padding(.bottom, 5) - if connected { - HStack(alignment: .bottom) { - Image(systemName: "repeat.circle.fill").font(.title2) .foregroundColor(.accentColor).symbolRenderingMode(.hierarchical) if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac { - Text("Currently Connected").font(.callout).foregroundColor(Color.accentColor) } else { - Text("Currently Connected").font(.title3).foregroundColor(Color.accentColor) } } .padding(.bottom, 2) } if node.positions?.count ?? 0 > 0 && (bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral.num != 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.coordinate != nil { - let nodeCoord = CLLocation(latitude: lastPostion.coordinate!.latitude, longitude: lastPostion.coordinate!.longitude) - let metersAway = nodeCoord.distance(from: myCoord) - Image(systemName: "lines.measurement.horizontal").font(.title3) .foregroundColor(.accentColor).symbolRenderingMode(.hierarchical) - if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac { - DistanceText(meters: metersAway).font(.subheadline).foregroundColor(.gray) - } else { - DistanceText(meters: metersAway).font(.title3).foregroundColor(.gray) } } } .padding(.bottom, 2) - } HStack(alignment: .bottom) { - Image(systemName: "clock.badge.checkmark.fill").font(.headline) .foregroundColor(.accentColor).symbolRenderingMode(.hierarchical) - LastHeardText(lastHeard: node.lastHeard).font(.subheadline).foregroundColor(.gray) } } @@ -128,25 +97,15 @@ struct NodeList: View { MeshtasticLogo() ) .onAppear { - - if initialLoad { - - self.bleManager.userSettings = userSettings - self.bleManager.context = context - self.initialLoad = false - } + self.bleManager.userSettings = userSettings + self.bleManager.context = context } } detail: { - if let node = selection { - NodeDetail(node:node) - } else { - Text("Select a node") } } - - } + } }