More map updates

This commit is contained in:
Garth Vander Houwen 2023-11-09 23:48:16 -08:00
parent 70e1bdb835
commit 992a560564
5 changed files with 26 additions and 22 deletions

View file

@ -26,6 +26,7 @@ struct ContentView: View {
.tag(Tab.nodes)
if #available(iOS 17.0, macOS 14.0, *) {
MeshMap()
//NodeMap()
.tabItem {
Label("map", systemImage: "map")
}

View file

@ -90,6 +90,7 @@ Spacer()
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.controlSize(.large)
.padding(.bottom)
#endif
}
.presentationDetents([.fraction(0.45), .fraction(0.65)])

View file

@ -128,6 +128,8 @@ struct PositionPopover: View {
if position.nodePosition != nil {
BatteryGauge(node: position.nodePosition!)
}
let mpInt = Int(position.nodePosition?.loRaConfig?.modemPreset ?? 0)
LoRaSignalStrengthMeter(snr: position.snr, rssi: position.rssi, preset: ModemPresets(rawValue: mpInt) ?? ModemPresets.longFast, compact: false)
}
}
.padding(.top)
@ -146,7 +148,7 @@ struct PositionPopover: View {
#endif
}
}
.presentationDetents([.fraction(0.45), .medium])
.presentationDetents([.fraction(0.45), .fraction(0.55), .fraction(0.65)])
.presentationDragIndicator(.visible)
}
}

View file

@ -13,14 +13,16 @@ struct WaypointPopover: View {
var waypoint: WaypointEntity
let distanceFormatter = MKDistanceFormatter()
var body: some View {
VStack (alignment: .leading) {
VStack {
HStack {
CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange)
CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange, circleSize: 65)
Spacer()
Text(waypoint.name ?? "?")
.font(.title3)
.font(.largeTitle)
Spacer()
if waypoint.locked > 0 {
Image(systemName: "lock.fill" )
.font(.title2)
.font(.largeTitle)
} else {
// Edit Button
}
@ -40,12 +42,10 @@ struct WaypointPopover: View {
.frame(width: 35)
}
.padding(.bottom, 5)
Divider()
}
/// Coordinate
Label {
Text("Coordinates: \(String(format: "%.6f", waypoint.coordinate.latitude)), \(String(format: "%.6f", waypoint.coordinate.longitude))")
//.font(.footnote)
.textSelection(.enabled)
.foregroundColor(.primary)
} icon: {
@ -54,7 +54,6 @@ struct WaypointPopover: View {
.frame(width: 35)
}
.padding(.bottom, 5)
Divider()
/// Created
Label {
Text("Created: \(waypoint.created?.formatted() ?? "?")")
@ -65,7 +64,6 @@ struct WaypointPopover: View {
.frame(width: 35)
}
.padding(.bottom, 5)
Divider()
/// Updated
if waypoint.lastUpdated != nil {
Label {
@ -77,7 +75,6 @@ struct WaypointPopover: View {
.frame(width: 35)
}
.padding(.bottom, 5)
Divider()
}
/// Expires
if waypoint.expire != nil {
@ -85,12 +82,11 @@ struct WaypointPopover: View {
Text("Expires: \(waypoint.expire?.formatted() ?? "?")")
.foregroundColor(.primary)
} icon: {
Image(systemName: "clock.badge.xmark")
Image(systemName: "hourglass.bottomhalf.filled")
.symbolRenderingMode(.hierarchical)
.frame(width: 35)
}
.padding(.bottom, 5)
Divider()
}
/// Distance
if LocationHelper.currentLocation.distance(from: LocationHelper.DefaultLocation) > 0.0 {
@ -104,10 +100,11 @@ struct WaypointPopover: View {
.frame(width: 35)
}
.padding(.bottom, 5)
Divider()
}
}
.padding(.top)
#if targetEnvironment(macCatalyst)
Spacer()
Button {
dismiss()
} label: {
@ -119,7 +116,7 @@ struct WaypointPopover: View {
.padding()
#endif
}
.presentationDetents([.fraction(0.3), .medium])
.presentationDetents([.fraction(0.5), .fraction(0.65)])
.tag(waypoint.id)
}
}

View file

@ -37,6 +37,7 @@ struct MeshMap: View {
@State var selectedPosition: PositionEntity?
@State var showWaypoints = false
@State var selectedWaypoint: WaypointEntity?
@State var newWaypointLocation :CLLocationCoordinate2D? = nil
var delay: Double = 0
@State private var scale: CGFloat = 0.5
@ -65,12 +66,11 @@ struct MeshMap: View {
ForEach(Array(waypoints), id: \.id) { waypoint in
Annotation(waypoint.name ?? "?", coordinate: waypoint.coordinate) {
ZStack {
CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange, circleSize: 35)
.onTapGesture(coordinateSpace: .named("meshmap")) { location in
print("Tapped at \(location)")
CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange, circleSize: 40)
.onTapGesture(perform: { location in
let pinLocation = reader.convert(location, from: .local)
selectedWaypoint = (selectedWaypoint == waypoint ? nil : waypoint)
}
})
}
}
}
@ -84,11 +84,9 @@ struct MeshMap: View {
//.stroke(Color(nodeColor.darker()), lineWidth: 3)
//.foregroundStyle(Color(nodeColor).opacity(0.4))
}
/// Position Annotations
ForEach(Array(positions), id: \.id) { position in
let pf = PositionFlags(rawValue: Int(position.nodePosition?.metadata?.positionFlags ?? 3))
/// Node Color from node.num
/// Node color from node.num
let nodeColor = UIColor(hex: UInt32(position.nodePosition?.num ?? 0))
Annotation(position.nodePosition?.user?.longName ?? "?", coordinate: position.coordinate) {
ZStack {
@ -134,7 +132,8 @@ struct MeshMap: View {
MapPolyline(coordinates: routeCoords)
.stroke(gradient, style: dashed)
}
} // Node History
}
/// Node History
if showNodeHistory {
ForEach(position.nodePosition!.positions!.reversed() as! [PositionEntity], id: \.self) { (mappin: PositionEntity) in
Annotation(position.latest ? position.nodePosition?.user?.shortName ?? "?": "", coordinate: position.coordinate) {
@ -152,6 +151,10 @@ struct MeshMap: View {
}
}
}
.onTapGesture(perform: { screenCoord in
newWaypointLocation = reader.convert(screenCoord, from: .local)
print("Tapped at \(newWaypointLocation)")
})
}
}
.mapScope(mapScope)