Skip to content

Commit

Permalink
Show end of route even if remainingVoiceInstructions is nil
Browse files Browse the repository at this point in the history
Previously, having voice instructions was a requirement of ending the
route.

Now we'll end the route when banner instructions are done *and* only
consider voice instructions if there were any to begin with.

Note: This currently crashes do to another issue with the end of route
view controller: see #57
  • Loading branch information
michaelkirk committed Jun 13, 2024
1 parent eaee92b commit 3e791b8
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions MapboxCoreNavigation/RouteController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -424,19 +424,23 @@ extension RouteController: CLLocationManagerDelegate {

func updateRouteLegProgress(for location: CLLocation) {
let currentDestination = self.routeProgress.currentLeg.destination
guard let remainingVoiceInstructions = routeProgress.currentLegProgress.currentStepProgress.remainingSpokenInstructions else { return }

if self.routeProgress.currentLegProgress.remainingSteps.count <= 1, remainingVoiceInstructions.count == 0, currentDestination != self.previousArrivalWaypoint {
self.previousArrivalWaypoint = currentDestination
guard self.routeProgress.currentLegProgress.remainingSteps.count <= 1 else { return }

self.routeProgress.currentLegProgress.userHasArrivedAtWaypoint = true
if let remainingVoiceInstructions = routeProgress.currentLegProgress.currentStepProgress.remainingSpokenInstructions {
guard remainingVoiceInstructions.count == 0 else { return }
}
guard currentDestination != self.previousArrivalWaypoint else { return }

let advancesToNextLeg = self.delegate?.routeController?(self, didArriveAt: currentDestination) ?? true
self.previousArrivalWaypoint = currentDestination

if !self.routeProgress.isFinalLeg, advancesToNextLeg {
self.routeProgress.legIndex += 1
self.updateDistanceToManeuver()
}
self.routeProgress.currentLegProgress.userHasArrivedAtWaypoint = true

let advancesToNextLeg = self.delegate?.routeController?(self, didArriveAt: currentDestination) ?? true

if !self.routeProgress.isFinalLeg, advancesToNextLeg {
self.routeProgress.legIndex += 1
self.updateDistanceToManeuver()
}
}

Expand Down

0 comments on commit 3e791b8

Please sign in to comment.