Route start and finish

This commit is contained in:
Garth Vander Houwen 2023-11-21 23:26:35 -08:00
parent f6cb21d6d8
commit 926ea1ea67
3 changed files with 37 additions and 25 deletions

View file

@ -123,7 +123,7 @@ struct NodeMapSwiftUI: View {
.opacity(0.8)
.presentationCompactAdaptation(.popover)
}
} else {
Image(systemName: "flipphone")
.symbolEffect(.pulse.byLayer)
@ -140,7 +140,7 @@ struct NodeMapSwiftUI: View {
.opacity(0.8)
.presentationCompactAdaptation(.popover)
}
}
} else {
if showNodeHistory {
@ -153,7 +153,7 @@ struct NodeMapSwiftUI: View {
.clipShape(Circle())
.rotationEffect(headingDegrees)
.frame(width: 16, height: 16)
} else {
Circle()
.fill(Color(UIColor(hex: UInt32(node.num))))
@ -282,8 +282,8 @@ struct NodeMapSwiftUI: View {
showWaypoints = !showWaypoints
}
}) {
Image(systemName: showWaypoints ? "signpost.right.and.left.fill" : "signpost.right.and.left")
.padding(.vertical, 5)
Image(systemName: showWaypoints ? "signpost.right.and.left.fill" : "signpost.right.and.left")
.padding(.vertical, 5)
}
.tint(Color(UIColor.secondarySystemBackground))
.foregroundColor(.accentColor)
@ -319,13 +319,13 @@ struct NodeMapSwiftUI: View {
.foregroundColor(.accentColor)
.buttonStyle(.borderedProminent)
}
#if targetEnvironment(macCatalyst)
#if targetEnvironment(macCatalyst)
/// Hide non fuctional catalyst controls
// MapZoomStepper(scope: mapScope)
// .mapControlVisibility(.visible)
// MapPitchSlider(scope: mapScope)
// .mapControlVisibility(.visible)
#endif
// MapZoomStepper(scope: mapScope)
// .mapControlVisibility(.visible)
// MapPitchSlider(scope: mapScope)
// .mapControlVisibility(.visible)
#endif
}
.controlSize(.regular)
.padding(5)

View file

@ -33,9 +33,8 @@ struct Routes: View {
) { result in
do {
guard let selectedFile: URL = try result.get().first else { return }
guard selectedFile.startAccessingSecurityScopedResource() else { // Notice this line right here
return
guard selectedFile.startAccessingSecurityScopedResource() else {
return
}
do {
@ -79,7 +78,7 @@ struct Routes: View {
print("Error: \(error.localizedDescription)")
}
}
} catch {
print("error: \(error)") // to do deal with errors
}
@ -97,7 +96,7 @@ struct Routes: View {
.listStyle(.plain)
}
.navigationTitle("Route List")
} detail: {
} detail: {
VStack {
if selectedRoute != nil {
let locationArray = selectedRoute?.locations?.array as? [LocationEntity] ?? []
@ -105,18 +104,31 @@ struct Routes: View {
return location.locationCoordinate ?? LocationHelper.DefaultLocation
})
Map () {
let gradient = LinearGradient(
colors: [.cyan, .blue, .secondary],//[Color(nodeColor.lighter().lighter()), Color(nodeColor.lighter()), Color(nodeColor)],
startPoint: .leading, endPoint: .trailing
)
Map() {
Annotation("Start", coordinate: lineCoords.first ?? LocationHelper.DefaultLocation) {
ZStack {
Circle()
.fill(Color(.green))
.strokeBorder(.white, lineWidth: 3)
.frame(width: 15, height: 15)
}
}
.annotationTitles(.automatic)
Annotation("Finish", coordinate: locationArray.last?.locationCoordinate ?? LocationHelper.DefaultLocation) {
ZStack {
Circle()
.fill(Color(.black))
.strokeBorder(.white, lineWidth: 3)
.frame(width: 15, height: 15)
}
}
.annotationTitles(.automatic)
let dashed = StrokeStyle(
lineWidth: 3,
lineCap: .round, lineJoin: .round, dash: [10, 10]
lineCap: .round, lineJoin: .round, dash: [7, 10]
)
MapPolyline(coordinates: lineCoords)
.stroke(gradient, style: dashed)
.stroke(.green, style: dashed)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}

View file

@ -62,7 +62,7 @@ struct Settings: View {
NavigationLink {
Routes()
} label: {
Image(systemName: "gearshape")
Image(systemName: "road.lanes.curved.right")
.symbolRenderingMode(.hierarchical)
Text("routes")
}