From 3a828ee0ff70e71c6e7686c22912e44cbe888757 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 16 Jan 2022 16:58:23 -0800 Subject: [PATCH] Try passing context into map view --- MeshtasticClient/Views/Map/MapViewModule.swift | 9 ++++++--- MeshtasticClient/Views/Nodes/NodeMap.swift | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/MeshtasticClient/Views/Map/MapViewModule.swift b/MeshtasticClient/Views/Map/MapViewModule.swift index dddcc826..adb33419 100644 --- a/MeshtasticClient/Views/Map/MapViewModule.swift +++ b/MeshtasticClient/Views/Map/MapViewModule.swift @@ -11,7 +11,9 @@ import CoreData #if canImport(MapKit) && canImport(UIKit) public struct MapView: UIViewRepresentable { - @Environment(\.managedObjectContext) var context + //@Environment(\.managedObjectContext) var context + + var context: NSManagedObjectContext? //@Binding private var region: MKCoordinateRegion @@ -60,7 +62,8 @@ public struct MapView: UIViewRepresentable { userLocation: Binding = .constant(nil), //annotations: [MKPointAnnotation] = [], //locationNodes: [NodeInfoEntity] = [], - overlays: [Overlay] = [] + overlays: [Overlay] = [], + context: NSManagedObjectContext? = nil ) { //self._region = region @@ -97,7 +100,7 @@ public struct MapView: UIViewRepresentable { //self.annotations = annotations - self.locationNodes = locationNodes + //self.locationNodes = locationNodes self.overlays = overlays diff --git a/MeshtasticClient/Views/Nodes/NodeMap.swift b/MeshtasticClient/Views/Nodes/NodeMap.swift index b9cc26b1..fd4517f4 100644 --- a/MeshtasticClient/Views/Nodes/NodeMap.swift +++ b/MeshtasticClient/Views/Nodes/NodeMap.swift @@ -108,14 +108,16 @@ struct NodeMap: View { userLocation: self.$userLocation, //annotations: self.annotations, //locationNodes: self.locationNodes.map({ nodeinfo in return nodeinfo }), - overlays: self.overlays + overlays: self.overlays, + context: self.context ) - + .frame(maxHeight: .infinity) .ignoresSafeArea(.all, edges: [.leading, .trailing]) } .navigationTitle("Mesh Map") .navigationBarTitleDisplayMode(.inline) + .navigationBarItems(trailing: ZStack {