-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS Route Overview #330
base: main
Are you sure you want to change the base?
iOS Route Overview #330
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import FerrostarCore | ||
import MapLibre | ||
import MapLibreSwiftUI | ||
|
||
extension NavigationState { | ||
var routeOverviewCamera: MapViewCamera? { | ||
guard let firstCoordinate = routeGeometry.first else { | ||
return nil | ||
} | ||
|
||
let initial = MLNCoordinateBounds( | ||
sw: firstCoordinate.clLocationCoordinate2D, | ||
ne: firstCoordinate.clLocationCoordinate2D | ||
) | ||
let bounds = routeGeometry.reduce(initial) { acc, coord in | ||
MLNCoordinateBounds( | ||
sw: CLLocationCoordinate2D(latitude: min(acc.sw.latitude, coord.lat), longitude: min( | ||
acc.sw.longitude, | ||
coord.lng | ||
)), | ||
ne: CLLocationCoordinate2D( | ||
latitude: max(acc.ne.latitude, coord.lat), | ||
longitude: max(acc.ne.longitude, coord.lng) | ||
) | ||
) | ||
} | ||
|
||
return MapViewCamera.boundingBox(bounds, edgePadding: UIEdgeInsets(top: 20, left: 100, bottom: 20, right: 100)) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ public struct DynamicallyOrientingNavigationView: View, CustomizableNavigatingIn | |
public var topCenter: (() -> AnyView)? | ||
public var topTrailing: (() -> AnyView)? | ||
public var midLeading: (() -> AnyView)? | ||
public var bottomLeading: (() -> AnyView)? | ||
public var bottomTrailing: (() -> AnyView)? | ||
|
||
let isMuted: Bool | ||
|
@@ -106,8 +107,13 @@ public struct DynamicallyOrientingNavigationView: View, CustomizableNavigatingIn | |
showZoom: true, | ||
onZoomIn: { camera.incrementZoom(by: 1) }, | ||
onZoomOut: { camera.incrementZoom(by: -1) }, | ||
showCentering: !camera.isTrackingUserLocationWithCourse, | ||
onCenter: { camera = navigationCamera }, | ||
cameraControlState: camera.isTrackingUserLocationWithCourse ? .showRouteOverview { | ||
if let overviewCamera = navigationState?.routeOverviewCamera { | ||
camera = overviewCamera | ||
} | ||
} : .showRecenter { // TODO: Third case when not navigating! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TBD the best way to express this logic given the limits of view code; probably in an extension / helper function. |
||
camera = navigationCamera | ||
}, | ||
onTapExit: onTapExit, | ||
currentRoadNameView: currentRoadNameView | ||
) | ||
|
@@ -117,6 +123,8 @@ public struct DynamicallyOrientingNavigationView: View, CustomizableNavigatingIn | |
topTrailing?() | ||
} midLeading: { | ||
midLeading?() | ||
} bottomLeading: { | ||
bottomLeading?() | ||
Comment on lines
+126
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Undo this change; recenter will stay in lower left corner. |
||
} bottomTrailing: { | ||
bottomTrailing?() | ||
}.complementSafeAreaInsets(parentGeometry: geometry, minimumInsets: minimumSafeAreaInsets) | ||
|
@@ -131,8 +139,13 @@ public struct DynamicallyOrientingNavigationView: View, CustomizableNavigatingIn | |
showZoom: true, | ||
onZoomIn: { camera.incrementZoom(by: 1) }, | ||
onZoomOut: { camera.incrementZoom(by: -1) }, | ||
showCentering: !camera.isTrackingUserLocationWithCourse, | ||
onCenter: { camera = navigationCamera }, | ||
cameraControlState: camera.isTrackingUserLocationWithCourse ? .showRouteOverview { | ||
if let overviewCamera = navigationState?.routeOverviewCamera { | ||
camera = overviewCamera | ||
} | ||
} : .showRecenter { // TODO: Third case when not navigating! | ||
camera = navigationCamera | ||
}, | ||
onTapExit: onTapExit, | ||
currentRoadNameView: currentRoadNameView | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The padding values are silly because the implementation in the MapLibre SwiftUI DSL seems to be broken.