From 669fb6de6baa249e75e67005c0236888eacccb83 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 7 Oct 2021 21:36:42 -0700 Subject: [PATCH] Remove extraneous vstack to fix swipe to disconnect and swipe to delete node --- MeshtasticClient/Helpers/BLEManager.swift | 3 ++ .../Views/Bluetooth/Connect.swift | 4 +- MeshtasticClient/Views/Nodes/NodeList.swift | 4 +- MeshtasticClient/Views/Nodes/NodeRow.swift | 51 ++++++++++++++----- 4 files changed, 43 insertions(+), 19 deletions(-) diff --git a/MeshtasticClient/Helpers/BLEManager.swift b/MeshtasticClient/Helpers/BLEManager.swift index 9a0c61ea..da11f16d 100644 --- a/MeshtasticClient/Helpers/BLEManager.swift +++ b/MeshtasticClient/Helpers/BLEManager.swift @@ -77,6 +77,9 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph if connectedPeripheral != nil && connectedPeripheral.peripheral.state == CBPeripheralState.connected { self.centralManager?.cancelPeripheralConnection(connectedPeripheral.peripheral) + } else { + connectedNode = nil + connectedPeripheral = nil } } diff --git a/MeshtasticClient/Views/Bluetooth/Connect.swift b/MeshtasticClient/Views/Bluetooth/Connect.swift index cf65add1..9aa1c980 100644 --- a/MeshtasticClient/Views/Bluetooth/Connect.swift +++ b/MeshtasticClient/Views/Bluetooth/Connect.swift @@ -56,9 +56,7 @@ struct Connect: View { Button { bleManager.disconnectDevice() } label: { - VStack { - Label("Disconnect", systemImage: "antenna.radiowaves.left.and.right.slash") - } + Label("Disconnect", systemImage: "antenna.radiowaves.left.and.right.slash") } .tint(.red) } diff --git a/MeshtasticClient/Views/Nodes/NodeList.swift b/MeshtasticClient/Views/Nodes/NodeList.swift index b7be8bce..50f15c80 100644 --- a/MeshtasticClient/Views/Nodes/NodeList.swift +++ b/MeshtasticClient/Views/Nodes/NodeList.swift @@ -62,9 +62,7 @@ struct NodeList: View { meshData.nodes.remove(at: nodeIndex!) meshData.save() } label: { - VStack { - Label("Delete from app", systemImage: "trash") - } + Label("Delete from app", systemImage: "trash") } .tint(.red) } diff --git a/MeshtasticClient/Views/Nodes/NodeRow.swift b/MeshtasticClient/Views/Nodes/NodeRow.swift index 1a649474..989b4e66 100644 --- a/MeshtasticClient/Views/Nodes/NodeRow.swift +++ b/MeshtasticClient/Views/Nodes/NodeRow.swift @@ -10,23 +10,48 @@ struct NodeRow: View { HStack() { CircleText(text: node.user.shortName, color: Color.blue).offset(y: 1).padding(.trailing, 5) - Text(node.user.longName).font(.title2) + .offset(x: -15) + + if UIDevice.current.userInterfaceIdiom == .pad { + Text(node.user.longName).font(.headline) + .offset(x: -15) + } + else { + Text(node.user.longName).font(.title) + .offset(x: -15) + } } - .padding([.trailing]) + .padding(.bottom, 10) HStack (alignment: .bottom){ - Image(systemName: "timer.square").font(.headline).foregroundColor(.blue).symbolRenderingMode(.hierarchical) - - if connected { - Text("Currently Connected").font(.subheadline).foregroundColor(Color.accentColor) - } - else if node.lastHeard > 0 { - let lastHeard = Date(timeIntervalSince1970: TimeInterval(node.lastHeard)) - Text("Last Heard: \(lastHeard, style: .relative) ago").font(.subheadline).foregroundColor(.gray) - } - else { - Text("Last Heard: Unknown").font(.subheadline).foregroundColor(.gray) + Image(systemName: "clock.badge.checkmark.fill").font(.headline).foregroundColor(.blue).symbolRenderingMode(.hierarchical) + + + if UIDevice.current.userInterfaceIdiom == .pad { + + if connected { + Text("Currently Connected").font(.caption).foregroundColor(Color.accentColor) + } + else if node.lastHeard > 0 { + let lastHeard = Date(timeIntervalSince1970: TimeInterval(node.lastHeard)) + Text("Last Heard: \(lastHeard, style: .relative) ago").font(.caption).foregroundColor(.gray) + } + else { + Text("Last Heard: Unknown").font(.caption).foregroundColor(.gray) + } + + } else { + if connected { + Text("Currently Connected").font(.subheadline).foregroundColor(Color.accentColor) + } + else if node.lastHeard > 0 { + let lastHeard = Date(timeIntervalSince1970: TimeInterval(node.lastHeard)) + Text("Last Heard: \(lastHeard, style: .relative) ago").font(.subheadline).foregroundColor(.gray) + } + else { + Text("Last Heard: Unknown").font(.subheadline).foregroundColor(.gray) + } } } }.padding([.leading, .top, .bottom])