From 38501624c2a505c0d0e9fd38774549f130fdfaf5 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 3 Sep 2023 20:23:40 -0700 Subject: [PATCH] fix map compass, add favorites feature to direct messages --- .../Views/Map/Custom/MapViewSwiftUI.swift | 19 ++++++++++--------- Meshtastic/Views/Messages/UserList.swift | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift index 10c32e2e..1620f184 100644 --- a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift @@ -75,23 +75,24 @@ struct MapViewSwiftUI: UIViewRepresentable { mapView.showsBuildings = true mapView.showsScale = true mapView.showsTraffic = true - #if targetEnvironment(macCatalyst) - // Show the default always visible compass and the mac only controls - mapView.showsCompass = true - mapView.showsZoomControls = true - mapView.showsPitchControl = true - #else - #if os(iOS) - // Move the default compass under the mapbuttons control + mapView.showsCompass = false let compass = MKCompassButton(mapView: mapView) compass.translatesAutoresizingMaskIntoConstraints = false + #if targetEnvironment(macCatalyst) + // Show the default always visible compass and the mac only controls + compass.compassVisibility = .visible + mapView.addSubview(compass) + mapView.showsZoomControls = true + mapView.showsPitchControl = true + compass.trailingAnchor.constraint(equalTo: mapView.trailingAnchor, constant: -115).isActive = true + compass.bottomAnchor.constraint(equalTo: mapView.bottomAnchor, constant: -5).isActive = true + #else compass.compassVisibility = .adaptive mapView.addSubview(compass) compass.trailingAnchor.constraint(equalTo: mapView.trailingAnchor, constant: -5).isActive = true compass.topAnchor.constraint(equalTo: mapView.topAnchor, constant: 145).isActive = true #endif - #endif } private func setMapBaseLayer(mapView: MKMapView) { // Avoid refreshing UI if selectedLayer has not changed diff --git a/Meshtastic/Views/Messages/UserList.swift b/Meshtastic/Views/Messages/UserList.swift index 1e88d615..d9fa02f4 100644 --- a/Meshtastic/Views/Messages/UserList.swift +++ b/Meshtastic/Views/Messages/UserList.swift @@ -24,7 +24,7 @@ struct UserList: View { @EnvironmentObject var bleManager: BLEManager @FetchRequest( - sortDescriptors: [NSSortDescriptor(key: "lastMessage", ascending: false), NSSortDescriptor(key: "longName", ascending: true)], + sortDescriptors: [NSSortDescriptor(key: "lastMessage", ascending: false), NSSortDescriptor(key: "vip", ascending: false), NSSortDescriptor(key: "longName", ascending: true)], animation: .default) private var users: FetchedResults @@ -63,7 +63,10 @@ struct UserList: View { Text(user.longName ?? "unknown".localized) Spacer() - + if user.vip { + Image(systemName: "star.fill") + .foregroundColor(.secondary) + } if user.messageList.count > 0 { if lastMessageDay == currentDay { Text(lastMessageTime, style: .time ) @@ -99,6 +102,17 @@ struct UserList: View { } .frame(height: 62) .contextMenu { + Button { + user.vip = !user.vip + do { + try context.save() + } catch { + context.rollback() + print("💥 Save User VIP Error") + } + } label: { + Label(user.vip ? "Un-Favorite" : "Favorite", systemImage: user.vip ? "star.fill" : "star.slash.fill") + } Button { user.mute = !user.mute do {