mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Map Cleanup, show waypoints button
This commit is contained in:
parent
f960198b8a
commit
48369fcc04
4 changed files with 75 additions and 37 deletions
|
|
@ -19,7 +19,7 @@ struct CircleText: View {
|
|||
Text(text)
|
||||
.textCase(.uppercase)
|
||||
.foregroundColor(color.isLight() ? .black : .white)
|
||||
.font(.system(size: 500))
|
||||
.font(.system(size: 8000))
|
||||
.minimumScaleFactor(0.001)
|
||||
.frame(width: circleSize * 0.95, height: circleSize * 0.95, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
|
|
@ -29,23 +29,40 @@ struct CircleText: View {
|
|||
|
||||
struct CircleText_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack {
|
||||
CircleText(text: "MOMO", color: Color.secondary, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "WWWW", color: Color.accentColor, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "LCP", color: Color.primary, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "69", color: Color.green, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "N1", color: Color.yellow, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "8", color: Color.purple, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "😝", color: Color.red, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "🍔", color: Color.brown, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
|
||||
HStack {
|
||||
VStack {
|
||||
|
||||
CircleText(text: "N1", color: Color.yellow, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "8", color: Color.purple, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "😝", color: Color.red, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "🍔", color: Color.brown, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "👻", color: Color.orange, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "🤙", color: Color.orange, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
|
||||
}
|
||||
VStack {
|
||||
CircleText(text: "69", color: Color.green, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "WWWW", color: Color.cyan, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "CW-A", color: Color.secondary)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "CW-A", color: Color.secondary, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "MOMO", color: Color.mint, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "IIII", color: Color.accentColor, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
CircleText(text: "LCP", color: Color.primary, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ struct NodeMapSwiftUI: View {
|
|||
@State var showUserLocation: Bool = false
|
||||
@State var positions: [PositionEntity] = []
|
||||
/// Map State User Defaults
|
||||
@AppStorage("meshMapShowNodeHistory") private var showNodeHistory = false
|
||||
@AppStorage("meshMapShowRouteLines") private var showRouteLines = false
|
||||
@AppStorage("enableMapConvexHull") private var showConvexHull = true
|
||||
@AppStorage("enableMapTraffic") private var showTraffic: Bool = true
|
||||
@AppStorage("enableMapPointsOfInterest") private var showPointsOfInterest: Bool = true
|
||||
@AppStorage("meshMapShowNodeHistory") private var showNodeHistory = true
|
||||
@AppStorage("meshMapShowRouteLines") private var showRouteLines = true
|
||||
@AppStorage("enableMapConvexHull") private var showConvexHull = false
|
||||
@AppStorage("enableMapTraffic") private var showTraffic: Bool = false
|
||||
@AppStorage("enableMapPointsOfInterest") private var showPointsOfInterest: Bool = false
|
||||
@AppStorage("mapLayer") private var selectedMapLayer: MapLayer = .hybrid
|
||||
// Map Configuration
|
||||
@Namespace var mapScope
|
||||
|
|
@ -35,6 +35,7 @@ struct NodeMapSwiftUI: View {
|
|||
@State var isLookingAround = false
|
||||
@State var isEditingSettings = false
|
||||
@State var selected: PositionEntity?
|
||||
@State var showWaypoints = false
|
||||
@State var selectedWaypoint: WaypointEntity?
|
||||
@State var showingPositionPopover = false
|
||||
|
||||
|
|
@ -80,17 +81,20 @@ struct NodeMapSwiftUI: View {
|
|||
.stroke(Color(nodeColor.darker()), lineWidth: 3)
|
||||
.foregroundStyle(Color(nodeColor).opacity(0.4))
|
||||
}
|
||||
|
||||
/// Waypoint Annotations
|
||||
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)
|
||||
if showWaypoints {
|
||||
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("nodemap")) { location in
|
||||
print("Tapped at \(location)")
|
||||
let pinLocation = reader.convert(location, from: .local)
|
||||
selectedWaypoint = (selectedWaypoint == waypoint ? nil : waypoint)
|
||||
}
|
||||
.onTapGesture(coordinateSpace: .named("nodemap")) { location in
|
||||
print("Tapped at \(location)")
|
||||
let pinLocation = reader.convert(location, from: .local)
|
||||
selectedWaypoint = (selectedWaypoint == waypoint ? nil : waypoint)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -195,9 +199,7 @@ struct NodeMapSwiftUI: View {
|
|||
}
|
||||
.sheet(item: $selectedWaypoint) { selection in
|
||||
WaypointPopover(waypoint: selection)
|
||||
.presentationDetents([.fraction(0.3), .medium])
|
||||
.padding()
|
||||
.opacity(0.8)
|
||||
}
|
||||
.sheet(isPresented: $isEditingSettings) {
|
||||
VStack {
|
||||
|
|
@ -283,6 +285,8 @@ struct NodeMapSwiftUI: View {
|
|||
#endif
|
||||
}
|
||||
.presentationDetents([.fraction(0.4), .medium])
|
||||
.presentationDragIndicator(.visible)
|
||||
|
||||
}
|
||||
.onChange(of: node) {
|
||||
let mostRecent = node.positions?.lastObject as? PositionEntity
|
||||
|
|
@ -324,6 +328,22 @@ struct NodeMapSwiftUI: View {
|
|||
.tint(Color(UIColor.secondarySystemBackground))
|
||||
.foregroundColor(.accentColor)
|
||||
.buttonStyle(.borderedProminent)
|
||||
|
||||
Button(action: {
|
||||
withAnimation {
|
||||
showWaypoints = !showWaypoints
|
||||
}
|
||||
}) {
|
||||
Image(systemName: showWaypoints ? "signpost.right.and.left.fill" : "signpost.right.and.left")
|
||||
.padding(.vertical, 5)
|
||||
}
|
||||
.tint(Color(UIColor.secondarySystemBackground))
|
||||
.foregroundColor(.accentColor)
|
||||
.buttonStyle(.borderedProminent)
|
||||
|
||||
|
||||
|
||||
|
||||
/// Look Around Button
|
||||
if self.scene != nil {
|
||||
Button(action: {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ struct PositionPopover: View {
|
|||
var position: PositionEntity
|
||||
let distanceFormatter = MKDistanceFormatter()
|
||||
var body: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
VStack (alignment: .leading) {
|
||||
HStack {
|
||||
CircleText(text: position.nodePosition?.user?.shortName ?? "?", color: Color(UIColor(hex: UInt32(position.nodePosition?.user?.num ?? 0))))
|
||||
Text(position.nodePosition?.user?.longName ?? "Unknown")
|
||||
.font(.title3)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ struct WaypointPopover: View {
|
|||
var waypoint: WaypointEntity
|
||||
let distanceFormatter = MKDistanceFormatter()
|
||||
var body: some View {
|
||||
VStack {
|
||||
VStack (alignment: .leading) {
|
||||
HStack {
|
||||
CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange)
|
||||
Text(waypoint.name ?? "?")
|
||||
|
|
@ -119,6 +119,7 @@ struct WaypointPopover: View {
|
|||
.padding()
|
||||
#endif
|
||||
}
|
||||
.presentationDetents([.fraction(0.3), .medium])
|
||||
.tag(waypoint.id)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue