mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Merge pull request #1234 from RCGV1/Favorite-Only-Map-Filter
Added Favorites Only Map Option
This commit is contained in:
commit
4584d5f5ce
4 changed files with 33 additions and 6 deletions
|
|
@ -20686,6 +20686,9 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Only Show Favorites" : {
|
||||
|
||||
},
|
||||
"Open Location Code (aka Plus Codes)" : {
|
||||
"localizations" : {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue