From 822028fb7bb4c2c29ac12ed7328b9200e8d12fb0 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 21 Feb 2023 19:03:11 -0800 Subject: [PATCH] Pin Icons for device roles --- Meshtastic/Enums/AppSettingsEnums.swift | 24 +++++++++++++++++++ .../contents | 1 + .../Views/Map/Custom/MapViewSwiftUI.swift | 24 ++++++++++++++++--- Meshtastic/Views/Settings/AppSettings.swift | 23 ++++++++++++------ de.lproj/Localizable.strings | 1 + en.lproj/Localizable.strings | 3 ++- zh-Hans.lproj/Localizable.strings | 1 + 7 files changed, 66 insertions(+), 11 deletions(-) diff --git a/Meshtastic/Enums/AppSettingsEnums.swift b/Meshtastic/Enums/AppSettingsEnums.swift index 53ce177b..32beae6d 100644 --- a/Meshtastic/Enums/AppSettingsEnums.swift +++ b/Meshtastic/Enums/AppSettingsEnums.swift @@ -35,6 +35,30 @@ enum KeyboardType: Int, CaseIterable, Identifiable { } } +enum CenteringMode: Int, CaseIterable, Identifiable { + + case allAnnotations = 0 + case allPositions = 1 + case latestPosition = 2 + case clientGps = 7 + + var id: Int { self.rawValue } + var description: String { + get { + switch self { + case .allAnnotations: + return "Center of All Annotations"// NSLocalizedString("default", comment: "Default Keyboard") + case .allPositions: + return "Center of All Node Postions"// NSLocalizedString("ascii.capable", comment: "ASCII Capable Keyboard") + case .latestPosition: + return "Latest Node Position"//NSLocalizedString("twitter", comment: "Twitter Keyboard") + case .clientGps: + return "Client GPS Location"//NSLocalizedString("email.address", comment: "Email Address Keyboard") + } + } + } +} + enum MeshMapType: String, CaseIterable, Identifiable { case standard = "standard" diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV8.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV8.xcdatamodel/contents index 1945a68a..a3184912 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV8.xcdatamodel/contents +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV8.xcdatamodel/contents @@ -219,6 +219,7 @@ + diff --git a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift index de52d486..503c908b 100644 --- a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift @@ -43,6 +43,7 @@ struct MapViewSwiftUI: UIViewRepresentable { mapView.mapType = mapViewType mapView.setUserTrackingMode(.none, animated: true) // Other MKMapView Settings + mapView.preferredConfiguration.elevationStyle = .realistic mapView.isPitchEnabled = true mapView.isRotateEnabled = true mapView.isScrollEnabled = true @@ -54,6 +55,9 @@ struct MapViewSwiftUI: UIViewRepresentable { mapView.showsUserLocation = true #if targetEnvironment(macCatalyst) mapView.showsZoomControls = true + mapView.showsPitchControl = true + #else + mapView.showsPointsOfInterest = true #endif mapView.delegate = context.coordinator return mapView @@ -144,6 +148,9 @@ struct MapViewSwiftUI: UIViewRepresentable { annotationView.titleVisibility = .adaptive } + + //annotationView.tag = -1 + annotationView.canShowCallout = true annotationView.titleVisibility = .adaptive let leftIcon = UIImageView(image: annotationView.glyphText?.image()) leftIcon.backgroundColor = UIColor(.indigo) @@ -155,6 +162,19 @@ struct MapViewSwiftUI: UIViewRepresentable { let distanceFormatter = MKDistanceFormatter() subtitle.text! += "Altitude: \(distanceFormatter.string(fromDistance: Double(positionAnnotation.altitude))) \n" if positionAnnotation.nodePosition?.metadata != nil { + + if DeviceRoles(rawValue: Int(positionAnnotation.nodePosition!.metadata?.role ?? 0)) == DeviceRoles.client || + DeviceRoles(rawValue: Int(positionAnnotation.nodePosition!.metadata?.role ?? 0)) == DeviceRoles.clientMute || + DeviceRoles(rawValue: Int(positionAnnotation.nodePosition!.metadata?.role ?? 0)) == DeviceRoles.routerClient{ + annotationView.glyphImage = UIImage(systemName: "flipphone") + } else if DeviceRoles(rawValue: Int(positionAnnotation.nodePosition!.metadata?.role ?? 0)) == DeviceRoles.repeater { + annotationView.glyphImage = UIImage(systemName: "repeat") + } else if DeviceRoles(rawValue: Int(positionAnnotation.nodePosition!.metadata?.role ?? 0)) == DeviceRoles.router { + annotationView.glyphImage = UIImage(systemName: "wifi.router.fill") + } else if DeviceRoles(rawValue: Int(positionAnnotation.nodePosition!.metadata?.role ?? 0)) == DeviceRoles.tracker { + annotationView.glyphImage = UIImage(systemName: "location.viewfinder") + } + let pf = PositionFlags(rawValue: Int(positionAnnotation.nodePosition?.metadata?.positionFlags ?? 3)) if pf.contains(.Satsinview) { subtitle.text! += "Sats in view: \(String(positionAnnotation.satsInView)) \n" @@ -171,11 +191,9 @@ struct MapViewSwiftUI: UIViewRepresentable { annotationView.glyphImage = UIImage(systemName: "location.north.fill")?.rotate(radians: Float(degreesToRadians(Double(positionAnnotation.heading)))) subtitle.text! += "Heading: \(String(positionAnnotation.heading)) \n" - } else { - annotationView.glyphText = "📟" } } else { - annotationView.glyphText = "📟" + annotationView.glyphImage = UIImage(systemName: "flipphone") } subtitle.text! += positionAnnotation.time?.formatted() ?? "Unknown \n" subtitle.numberOfLines = 0 diff --git a/Meshtastic/Views/Settings/AppSettings.swift b/Meshtastic/Views/Settings/AppSettings.swift index 5d616d47..e478e57c 100644 --- a/Meshtastic/Views/Settings/AppSettings.swift +++ b/Meshtastic/Views/Settings/AppSettings.swift @@ -60,14 +60,23 @@ struct AppSettings: View { } } - Section(header: Text("map options")) { + Section(header: Text("global map options")) { - Picker("map.type", selection: $userSettings.meshMapType) { - ForEach(MeshMapType.allCases) { map in - Text(map.description) - } - } - .pickerStyle(DefaultPickerStyle()) + Picker("map.type", selection: $userSettings.meshMapType) { + ForEach(MeshMapType.allCases) { map in + Text(map.description) + } + } + .pickerStyle(DefaultPickerStyle()) + } + + Section(header: Text("mesh map options")) { + Picker("map.centering", selection: $userSettings.meshMapType) { + ForEach(CenteringMode.allCases) { cm in + Text(cm.description) + } + } + .pickerStyle(DefaultPickerStyle()) } } HStack { diff --git a/de.lproj/Localizable.strings b/de.lproj/Localizable.strings index 32add33f..8db9471a 100644 --- a/de.lproj/Localizable.strings +++ b/de.lproj/Localizable.strings @@ -137,6 +137,7 @@ "lora"="LoRa"; "lora.config"="LoRa Einstellungen"; "map"="Mesh Karte"; +"map.centering"="Centering"; "map.type"="kartentyp"; "mesh.log"="Mesh Log"; "mesh.log.bluetooth.config %@"="Bluetooth Konfiguration empfangen: %@"; diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings index fc958b77..542377e5 100644 --- a/en.lproj/Localizable.strings +++ b/en.lproj/Localizable.strings @@ -137,7 +137,8 @@ "lora"="LoRa"; "lora.config"="LoRa Config"; "map"="Mesh Map"; -"map.type"="Map Type"; +"map.type"="Default Type"; +"map.centering"="Centering"; "mesh.log"="Mesh Log"; "mesh.log.bluetooth.config %@"="Bluetooth config received: %@"; "mesh.log.cannedmessage.config %@"="Canned Message module config received: %@"; diff --git a/zh-Hans.lproj/Localizable.strings b/zh-Hans.lproj/Localizable.strings index bf6c29d1..3a337e5a 100644 --- a/zh-Hans.lproj/Localizable.strings +++ b/zh-Hans.lproj/Localizable.strings @@ -137,6 +137,7 @@ "lora"="LoRa"; "lora.config"="LoRa 配置"; "map"="Mesh 地图"; +"map.centering"="Centering"; "map.type"="地图类型"; "mesh.log"="Mesh 日志"; "mesh.log.bluetooth.config %@"="Bluetooth config received: %@";