mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Merge pull request #918 from powersjcb/powersjcb/nodes-map-deep-links
add centerMapAt util to MeshMap
This commit is contained in:
commit
a40d194f32
3 changed files with 38 additions and 8 deletions
|
|
@ -33,6 +33,7 @@ struct MeshMap: View {
|
|||
@Namespace var mapScope
|
||||
@State var mapStyle: MapStyle = MapStyle.standard(elevation: .flat, emphasis: MapStyle.StandardEmphasis.muted, pointsOfInterest: .excludingAll, showsTraffic: false)
|
||||
@State var position = MapCameraPosition.automatic
|
||||
@State private var distance = 10000.0
|
||||
@State private var editingSettings = false
|
||||
@State private var editingFilters = false
|
||||
@State var selectedPosition: PositionEntity?
|
||||
|
|
@ -60,8 +61,19 @@ struct MeshMap: View {
|
|||
NavigationStack {
|
||||
ZStack {
|
||||
MapReader { reader in
|
||||
Map(position: $position, bounds: MapCameraBounds(minimumDistance: 1, maximumDistance: .infinity), scope: mapScope) {
|
||||
MeshMapContent(showUserLocation: $showUserLocation, showTraffic: $showTraffic, showPointsOfInterest: $showPointsOfInterest, selectedMapLayer: $selectedMapLayer, selectedPosition: $selectedPosition, selectedWaypoint: $selectedWaypoint)
|
||||
Map(
|
||||
position: $position,
|
||||
bounds: MapCameraBounds(minimumDistance: 1, maximumDistance: .infinity),
|
||||
scope: mapScope
|
||||
) {
|
||||
MeshMapContent(
|
||||
showUserLocation: $showUserLocation,
|
||||
showTraffic: $showTraffic,
|
||||
showPointsOfInterest: $showPointsOfInterest,
|
||||
selectedMapLayer: $selectedMapLayer,
|
||||
selectedPosition: $selectedPosition,
|
||||
selectedWaypoint: $selectedWaypoint
|
||||
)
|
||||
}
|
||||
.mapScope(mapScope)
|
||||
.mapStyle(mapStyle)
|
||||
|
|
@ -74,6 +86,9 @@ struct MeshMap: View {
|
|||
.mapControlVisibility(.automatic)
|
||||
}
|
||||
.controlSize(.regular)
|
||||
.onMapCameraChange(frequency: MapCameraUpdateFrequency.continuous, { context in
|
||||
distance = context.camera.distance
|
||||
})
|
||||
.onTapGesture(count: 1, perform: { position in
|
||||
newWaypointCoord = reader.convert(position, from: .local) ?? CLLocationCoordinate2D.init()
|
||||
})
|
||||
|
|
@ -92,6 +107,7 @@ struct MeshMap: View {
|
|||
Logger.services.error("Unable to convert local point to coordinate on map.")
|
||||
return
|
||||
}
|
||||
centerMapAt(coordinate: coordinate)
|
||||
|
||||
newWaypointCoord = coordinate
|
||||
editingWaypoint = WaypointEntity(context: context)
|
||||
|
|
@ -210,4 +226,18 @@ struct MeshMap: View {
|
|||
UIApplication.shared.isIdleTimerDisabled = false
|
||||
})
|
||||
}
|
||||
|
||||
// moves the map to a new coordinate
|
||||
private func centerMapAt(coordinate: CLLocationCoordinate2D) {
|
||||
withAnimation(.easeInOut(duration: 0.2), {
|
||||
position = .camera(
|
||||
MapCamera(
|
||||
centerCoordinate: coordinate, // Set new center
|
||||
distance: distance, // Preserve current zoom distance
|
||||
heading: 0, // align north
|
||||
pitch: 0 // set view to top down
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ struct WidgetsLiveActivity: Widget {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
struct WidgetsLiveActivity_Previews: PreviewProvider {
|
||||
static let attributes = MeshActivityAttributes(nodeNum: 123456789, name: "RAK Compact Rotary Handset Gray 8E6G")
|
||||
static let state = MeshActivityAttributes.ContentState(uptimeSeconds: 600, channelUtilization: 1.2, airtime: 3.5, sentPackets: 12587, receivedPackets: 12555, badReceivedPackets: 800, nodesOnline: 99, totalNodes: 100, timerRange: Date.now...Date(timeIntervalSinceNow: 300))
|
||||
|
|
@ -139,7 +140,6 @@ struct WidgetsLiveActivity_Previews: PreviewProvider {
|
|||
.previewDisplayName("Notification")
|
||||
}
|
||||
}
|
||||
|
||||
struct LiveActivityView: View {
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
@Environment(\.isLuminanceReduced) var isLuminanceReduced
|
||||
|
|
|
|||
|
|
@ -23,22 +23,22 @@ if [[ -e "${SWIFT_LINT}" ]]; then
|
|||
##### Fix files or exit if no files found for fixing #####
|
||||
if [ "$count" -ne 0 ]; then
|
||||
echo "Found files to fix! Running swiftLint --fix..."
|
||||
|
||||
|
||||
# Run SwiftLint --fix on each file
|
||||
for ((i = 0; i < count; i++)); do
|
||||
file_var="SCRIPT_INPUT_FILE_$i"
|
||||
file_path=${!file_var}
|
||||
echo "Fixing $file_path"
|
||||
$SWIFT_LINT --fix --path "$file_path"
|
||||
$SWIFT_LINT --fix "$file_path"
|
||||
done
|
||||
|
||||
|
||||
# Add the fixed files back to staging
|
||||
for ((i = 0; i < count; i++)); do
|
||||
file_var="SCRIPT_INPUT_FILE_$i"
|
||||
file_path=${!file_var}
|
||||
git add "$file_path"
|
||||
done
|
||||
|
||||
|
||||
echo "swiftLint --fix completed and files re-staged."
|
||||
|
||||
# Optionally lint the fixed files
|
||||
|
|
@ -61,4 +61,4 @@ if [[ -e "${SWIFT_LINT}" ]]; then
|
|||
else
|
||||
echo "SwiftLint not installed. Please install from https://github.com/realm/SwiftLint"
|
||||
exit -1
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue