Merge pull request #1234 from RCGV1/Favorite-Only-Map-Filter

Added Favorites Only Map Option
This commit is contained in:
Garth Vander Houwen 2025-05-23 23:45:37 -07:00 committed by GitHub
commit 4584d5f5ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 6 deletions

View file

@ -20686,6 +20686,9 @@
}
}
}
},
"Only Show Favorites" : {
},
"Open Location Code (aka Plus Codes)" : {
"localizations" : {

View file

@ -57,6 +57,7 @@ extension UserDefaults {
case enableMapTraffic
case enableMapPointsOfInterest
case enableOfflineMaps
case onlyShowFavoriteNodesMap
case mapTileServer
case enableOverlayServer
case mapOverlayServer
@ -118,6 +119,9 @@ extension UserDefaults {
@UserDefault(.enableMapPointsOfInterest, defaultValue: false)
static var enableMapPointsOfInterest: Bool
@UserDefault(.onlyShowFavoriteNodesMap, defaultValue: false)
static var onlyShowFavoriteNodesMap: Bool
@UserDefault(.enableDetectionNotifications, defaultValue: false)
static var enableDetectionNotifications: Bool

View file

@ -15,6 +15,7 @@ struct MeshMapContent: MapContent {
@AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false
@AppStorage("meshMapShowRouteLines") private var showRouteLines = false
@AppStorage("enableMapConvexHull") private var showConvexHull = false
@AppStorage("onlyShowFavoriteNodesMap") private var favoriteNodesOnly = false
@Binding var showTraffic: Bool
@Binding var showPointsOfInterest: Bool
@Binding var selectedMapLayer: MapLayer
@ -39,11 +40,12 @@ struct MeshMapContent: MapContent {
@MapContentBuilder
var positionAnnotations: some MapContent {
ForEach(positions, id: \.id) { position in
/// Node color from node.num
let nodeColor = UIColor(hex: UInt32(position.nodePosition?.num ?? 0))
let positionName = position.nodePosition?.user?.longName ?? "?"
/// Latest Position Anotations
Annotation(positionName, coordinate: position.coordinate) {
if !favoriteNodesOnly || (position.nodePosition?.favorite == true) {
/// Node color from node.num
let nodeColor = UIColor(hex: UInt32(position.nodePosition?.num ?? 0))
let positionName = position.nodePosition?.user?.longName ?? "?"
/// Latest Position Anotations
Annotation(positionName, coordinate: position.coordinate) {
LazyVStack {
ZStack {
let nodeColor = UIColor(hex: UInt32(position.nodePosition?.num ?? 0))
@ -59,6 +61,13 @@ struct MeshMapContent: MapContent {
.onAppear {
self.scale = 1
}
.onChange(of: favoriteNodesOnly) {
scale = 0.5 // Reset to initial state
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
scale = 1
}
}
.frame(width: 60, height: 60)
}
if position.nodePosition?.hasDetectionSensorMetrics ?? false {
@ -141,6 +150,8 @@ struct MeshMapContent: MapContent {
}
}
}
}
}
@MapContentBuilder

View file

@ -15,6 +15,7 @@ struct MapSettingsForm: View {
@AppStorage("meshMapShowRouteLines") private var routeLines = false
@AppStorage("enableMapConvexHull") private var convexHull = false
@AppStorage("enableMapWaypoints") private var waypoints = true
@AppStorage("onlyShowFavoriteNodesMap") private var favoriteNodesOnly = false
@Binding var traffic: Bool
@Binding var pointsOfInterest: Bool
@Binding var mapLayer: MapLayer
@ -61,7 +62,15 @@ struct MapSettingsForm: View {
UserDefaults.enableMapWaypoints = !waypoints
}
}
Toggle(isOn: $favoriteNodesOnly) {
Label("Only Show Favorites", systemImage: "star.fill")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
.onTapGesture {
self.favoriteNodesOnly.toggle()
UserDefaults.onlyShowFavoriteNodesMap = self.favoriteNodesOnly
}
Toggle(isOn: $nodeHistory) {
Label("Node History", systemImage: "building.columns.fill")
}