Meshtastic-Apple/MeshtasticClient/Views/Nodes/NodeMap.swift

70 lines
1.7 KiB
Swift
Raw Normal View History

2021-08-20 07:56:05 -07:00
//
2021-11-29 21:35:23 -08:00
// NodeMap.swift
// MeshtasticClient
2021-08-20 07:56:05 -07:00
//
// Created by Garth Vander Houwen on 8/7/21.
// Copyright © 2021 Apple. All rights reserved.
//
import SwiftUI
import MapKit
import CoreLocation
2021-12-20 22:29:28 -08:00
import CoreData
2021-08-20 07:56:05 -07:00
struct NodeMap: View {
2021-11-29 15:59:06 -08:00
2021-12-15 23:53:45 -08:00
@Environment(\.managedObjectContext) var context
2021-11-29 15:59:06 -08:00
@EnvironmentObject var bleManager: BLEManager
2021-12-25 23:48:12 -08:00
// @AppStorage("meshMapType") var meshMapType: String = "hybrid"
2021-12-20 22:29:28 -08:00
@State private var showLabels: Bool = false
2021-12-25 23:48:12 -08:00
2021-12-20 22:29:28 -08:00
@State private var annotationItems: [MapLocation] = []
@FetchRequest( sortDescriptors: [NSSortDescriptor(keyPath: \NodeInfoEntity.lastHeard, ascending: false)], animation: .default)
2021-12-25 23:48:12 -08:00
2021-12-15 23:53:45 -08:00
private var locationNodes: FetchedResults<NodeInfoEntity>
2021-12-25 23:48:12 -08:00
2021-08-20 07:56:05 -07:00
var body: some View {
2021-12-25 23:48:12 -08:00
let location = LocationHelper.currentLocation
2021-11-29 15:59:06 -08:00
2021-12-25 23:48:12 -08:00
NavigationView {
2021-12-24 20:18:42 +13:00
ZStack {
2021-12-25 23:48:12 -08:00
MapView(nodes: self.locationNodes)//.environmentObject(bleManager)
2021-12-25 23:48:12 -08:00
// }
.frame(maxHeight: .infinity)
2021-12-20 22:29:28 -08:00
.ignoresSafeArea(.all, edges: [.leading, .trailing])
}
.navigationTitle("Mesh Map")
.navigationBarTitleDisplayMode(.inline)
.navigationBarItems(trailing:
2021-11-29 15:59:06 -08:00
ZStack {
ConnectedDevice(
bluetoothOn: bleManager.isSwitchedOn,
deviceConnected: bleManager.connectedPeripheral != nil,
name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName :
"???")
})
.onAppear(perform: {
self.bleManager.context = context
2021-11-29 15:59:06 -08:00
})
}
.navigationViewStyle(StackNavigationViewStyle())
2021-08-20 07:56:05 -07:00
}
}
2021-09-18 21:11:54 -07:00
struct NodeMap_Previews: PreviewProvider {
static let bleManager = BLEManager()
2021-09-18 21:11:54 -07:00
static var previews: some View {
NodeMap()
2021-09-18 21:11:54 -07:00
}
}