Skip to content
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

Add delegates to NavigationViewController. #4175

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions MapboxNavigation.xcodeproj/project.pbxproj
Expand Up @@ -264,6 +264,7 @@
8AC40920279918930075248E /* NavigationViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC4091F279918930075248E /* NavigationViewDelegate.swift */; };
8AC5070728D3D925005D45EB /* CameraModeFloatingButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC5070628D3D925005D45EB /* CameraModeFloatingButton.swift */; };
8AC5070928D3D930005D45EB /* CameraModeFloatingButtonDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC5070828D3D930005D45EB /* CameraModeFloatingButtonDelegate.swift */; };
8AC5070C28D3F6E3005D45EB /* NavigationViewController+NavigationMapViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC5070B28D3F6E3005D45EB /* NavigationViewController+NavigationMapViewDelegate.swift */; };
8AC85EA428628E4F003F8FC8 /* UIDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC85EA328628E4F003F8FC8 /* UIDevice.swift */; };
8ACF0AAA2706394A00F30423 /* CPInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ACF0AA92706394A00F30423 /* CPInterfaceController.swift */; };
8AD12F4C26C193560008AE55 /* LeaksTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AD12F4826C193520008AE55 /* LeaksTests.swift */; };
Expand Down Expand Up @@ -864,6 +865,7 @@
8AC4091F279918930075248E /* NavigationViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationViewDelegate.swift; sourceTree = "<group>"; };
8AC5070628D3D925005D45EB /* CameraModeFloatingButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraModeFloatingButton.swift; sourceTree = "<group>"; };
8AC5070828D3D930005D45EB /* CameraModeFloatingButtonDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraModeFloatingButtonDelegate.swift; sourceTree = "<group>"; };
8AC5070B28D3F6E3005D45EB /* NavigationViewController+NavigationMapViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NavigationViewController+NavigationMapViewDelegate.swift"; sourceTree = "<group>"; };
8AC85EA328628E4F003F8FC8 /* UIDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIDevice.swift; sourceTree = "<group>"; };
8ACF0AA92706394A00F30423 /* CPInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CPInterfaceController.swift; sourceTree = "<group>"; };
8AD12F4326C191080008AE55 /* Snapshot++.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Snapshot++.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1979,6 +1981,7 @@
8A11FEEF27A3514C00285B6F /* CPRouteChoice.swift */,
8AD220AA27C091EE000734A5 /* Solar.swift */,
8AD220AE27C09544000734A5 /* Date.swift */,
8AC5070B28D3F6E3005D45EB /* NavigationViewController+NavigationMapViewDelegate.swift */,
);
name = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -2790,6 +2793,7 @@
C57491DF1FACC42F006F97BC /* CGPoint.swift in Sources */,
8A50A3C426EC09FB00894A8E /* FeedbackViewController.swift in Sources */,
B4E19C47268114840011581F /* NavigationLocationProvider.swift in Sources */,
8AC5070C28D3F6E3005D45EB /* NavigationViewController+NavigationMapViewDelegate.swift in Sources */,
16C2A421211526EE00FE6E68 /* CarPlayManager.swift in Sources */,
8AA0386327F7B3F50007BD2D /* BottomBannerViewControllerDelegate.swift in Sources */,
8D53136B20653FA20044891E /* ExitView.swift in Sources */,
Expand Down
@@ -0,0 +1,80 @@
import MapboxMaps
import MapboxDirections
import MapboxCoreNavigation

// MARK: NavigationMapViewDelegate methods

extension NavigationViewController: NavigationMapViewDelegate {

public func navigationMapView(_ navigationMapView: NavigationMapView,
routeLineLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> LineLayer? {
delegate?.navigationViewController(self,
routeLineLayerWithIdentifier: identifier,
sourceIdentifier: sourceIdentifier)
}

public func navigationMapView(_ navigationMapView: NavigationMapView,
routeCasingLineLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> LineLayer? {
delegate?.navigationViewController(self,
routeCasingLineLayerWithIdentifier: identifier,
sourceIdentifier: sourceIdentifier)
}

public func navigationMapView(_ navigationMapView: NavigationMapView,
routeRestrictedAreasLineLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> LineLayer? {
delegate?.navigationViewController(self,
routeRestrictedAreasLineLayerWithIdentifier: identifier,
sourceIdentifier: sourceIdentifier)
}

public func navigationMapView(_ navigationMapView: NavigationMapView,
waypointCircleLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> CircleLayer? {
delegate?.navigationViewController(self,
waypointCircleLayerWithIdentifier: identifier,
sourceIdentifier: sourceIdentifier)
}

public func navigationMapView(_ navigationMapView: NavigationMapView,
waypointSymbolLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> SymbolLayer? {
delegate?.navigationViewController(self,
waypointSymbolLayerWithIdentifier: identifier,
sourceIdentifier: sourceIdentifier)
}

public func navigationMapView(_ navigationMapView: NavigationMapView,
shapeFor waypoints: [Waypoint],
legIndex: Int) -> FeatureCollection? {
delegate?.navigationViewController(self,
shapeFor: waypoints,
legIndex: legIndex)
}

public func navigationMapView(_ navigationMapView: NavigationMapView,
didAdd finalDestinationAnnotation: PointAnnotation,
pointAnnotationManager: PointAnnotationManager) {
delegate?.navigationViewController(self,
didAdd: finalDestinationAnnotation,
pointAnnotationManager: pointAnnotationManager)
}

public func navigationMapView(_ navigationMapView: NavigationMapView,
didSelect waypoint: Waypoint) {
delegate?.navigationViewController(self,
didSelect: waypoint)
}

public func navigationMapView(_ navigationMapView: NavigationMapView,
didSelect continuousAlternative: AlternativeRoute) {
router.updateRoute(with: continuousAlternative.indexedRouteResponse,
routeOptions: nil,
completion: nil)

delegate?.navigationViewController(self,
didSelect: continuousAlternative)
}
}
39 changes: 0 additions & 39 deletions Sources/MapboxNavigation/NavigationViewController.swift
Expand Up @@ -1317,42 +1317,3 @@ extension NavigationViewController: CarPlayConnectionObserver {
}
}
}

// MARK: NavigationMapViewDelegate methods

extension NavigationViewController: NavigationMapViewDelegate {

public func navigationMapView(_ navigationMapView: NavigationMapView, routeLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer? {
delegate?.navigationViewController(self, routeLineLayerWithIdentifier: identifier, sourceIdentifier: sourceIdentifier)
}

public func navigationMapView(_ navigationMapView: NavigationMapView, routeCasingLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer? {
delegate?.navigationViewController(self, routeCasingLineLayerWithIdentifier: identifier, sourceIdentifier: sourceIdentifier)
}

public func navigationMapView(_ navigationMapView: NavigationMapView, routeRestrictedAreasLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer? {
delegate?.navigationViewController(self, routeRestrictedAreasLineLayerWithIdentifier: identifier, sourceIdentifier: sourceIdentifier)
}

public func navigationMapView(_ navigationMapView: NavigationMapView, waypointCircleLayerWithIdentifier identifier: String, sourceIdentifier: String) -> CircleLayer? {
delegate?.navigationViewController(self, waypointCircleLayerWithIdentifier: identifier, sourceIdentifier: sourceIdentifier)
}

public func navigationMapView(_ navigationMapView: NavigationMapView, waypointSymbolLayerWithIdentifier identifier: String, sourceIdentifier: String) -> SymbolLayer? {
delegate?.navigationViewController(self, waypointSymbolLayerWithIdentifier: identifier, sourceIdentifier: sourceIdentifier)
}

public func navigationMapView(_ navigationMapView: NavigationMapView, shapeFor waypoints: [Waypoint], legIndex: Int) -> FeatureCollection? {
delegate?.navigationViewController(self, shapeFor: waypoints, legIndex: legIndex)
}

public func navigationMapView(_ navigationMapView: NavigationMapView, didAdd finalDestinationAnnotation: PointAnnotation, pointAnnotationManager: PointAnnotationManager) {
delegate?.navigationViewController(self, didAdd: finalDestinationAnnotation, pointAnnotationManager: pointAnnotationManager)
}

public func navigationMapView(_ navigationMapView: NavigationMapView, didSelect continuousAlternative: AlternativeRoute) {
router.updateRoute(with: continuousAlternative.indexedRouteResponse,
routeOptions: nil,
completion: nil)
}
}