From b6fd64ac0324e8a93106567f20b2aead54bb1b1b Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 17 Oct 2022 20:54:41 -0700 Subject: [PATCH] Selected sidebar list cleanup, still not perfect --- Meshtastic/Views/Messages/Contacts.swift | 35 +++-- Meshtastic/Views/Nodes/NodeList.swift | 163 +++++++++++------------ 2 files changed, 101 insertions(+), 97 deletions(-) diff --git a/Meshtastic/Views/Messages/Contacts.swift b/Meshtastic/Views/Messages/Contacts.swift index 7e31f0a9..a5a391f9 100644 --- a/Meshtastic/Views/Messages/Contacts.swift +++ b/Meshtastic/Views/Messages/Contacts.swift @@ -51,10 +51,10 @@ struct Contacts: View { let currentDay = Calendar.current.dateComponents([.day], from: Date()).day ?? 0 HStack { - VStack { + VStack(alignment: .leading) { CircleText(text: user.shortName ?? "???", color: Color.blue) + .padding(.trailing, 5) } - .padding([.leading, .trailing]) VStack { HStack { VStack { @@ -80,8 +80,6 @@ struct Contacts: View { } .frame(maxWidth: .infinity, alignment: .trailing) } - .listRowSeparator(.hidden).frame(height: 5) - HStack(alignment: .top) { Text("\(mostRecent != nil ? mostRecent!.messagePayload! : " ")") .frame(height: 60) @@ -94,10 +92,10 @@ struct Contacts: View { } } else { HStack { - VStack { - CircleText(text: user.shortName ?? "????", color: Color.blue) + VStack(alignment: .leading) { + CircleText(text: user.shortName ?? "???", color: Color.blue) + .padding(.trailing, 5) } - .padding(.trailing) VStack { HStack { VStack { @@ -108,9 +106,16 @@ struct Contacts: View { } .frame(maxWidth: .infinity, alignment: .trailing) } - .listRowSeparator(.hidden).frame(height: 5) + HStack(alignment: .top) { + Text(" ") + .frame(height: 60) + .truncationMode(.tail) + .foregroundColor(Color.gray) + .frame(maxWidth: .infinity, alignment: .leading) + } } - }.padding() + .padding(.top) + } } } } @@ -122,11 +127,7 @@ struct Contacts: View { } .hidden() } - .navigationTitle("Contacts") - .navigationBarTitleDisplayMode(.inline) - .navigationBarItems(leading: - MeshtasticLogo() - ) + .tint(Color(UIColor.systemGray)) } detail: { @@ -139,5 +140,11 @@ struct Contacts: View { Text("Select a user") } } + .navigationSplitViewStyle(.automatic) + .navigationTitle("Contacts") + .navigationBarTitleDisplayMode(.inline) + .navigationBarItems(leading: + MeshtasticLogo() + ) } } diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 9314ce27..11a720a5 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -44,101 +44,85 @@ struct NodeList: View { .listRowSeparator(.visible) } else { - //ForEach( nodes ) { node in - // let index = nodes.firstIndex(where: { $0.id == node.id }) + NavigationLink(value: node) { - NavigationLink(value: node) { + let connected: Bool = (bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral.num == node.num) - let connected: Bool = (bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral.num == node.num) + VStack(alignment: .leading) { - VStack(alignment: .leading) { + HStack { - HStack { + CircleText(text: node.user?.shortName ?? "???", color: .blue).offset(y: 1).padding(.trailing, 5) + .offset(x: -15) - CircleText(text: node.user?.shortName ?? "???", color: Color.accentColor).offset(y: 1).padding(.trailing, 5) + if UIDevice.current.userInterfaceIdiom == .pad { Text(node.user?.longName ?? "Unknown").font(.headline) .offset(x: -15) - - if UIDevice.current.userInterfaceIdiom == .pad { Text(node.user?.longName ?? "Unknown").font(.headline) - .offset(x: -15) - } else { - Text(node.user?.longName ?? "Unknown").font(.title2).offset(x: -15) - } - } - .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) + } else { + Text(node.user?.longName ?? "Unknown").font(.title2).offset(x: -15) } } - .padding([.leading, .top, .bottom]) + .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) + } } - //} + .padding([.leading, .top, .bottom]) + } } } - .navigationTitle("All Nodes") - .navigationBarItems(leading: - MeshtasticLogo() - ) - .onAppear { - - if initialLoad { - - self.bleManager.userSettings = userSettings - self.bleManager.context = context - self.initialLoad = false - } - } + .tint(Color(UIColor.systemGray)) } detail: { if let node = selection { @@ -150,5 +134,18 @@ struct NodeList: View { Text("Select a node") } } + .navigationTitle("All Nodes") + .navigationBarItems(leading: + MeshtasticLogo() + ) + .onAppear { + + if initialLoad { + + self.bleManager.userSettings = userSettings + self.bleManager.context = context + self.initialLoad = false + } + } } }