Skip to content

Commit

Permalink
Restore the ability to init NavVC without animations.
Browse files Browse the repository at this point in the history
Prior to maplibre#54, the NavigationViewController could only be used modally.

With maplibre#54, you can switch between "map mode" and "navigation mode". To do
so, an animation was introduced for the sake of smoothly transitioning from "map mode" to "navigation mode".

However, if you are still using the NavigationViewController modally,
this animation might interfere with other things you were doing - like
setting the camera.
  • Loading branch information
michaelkirk committed Jun 25, 2024
1 parent 7c02808 commit b53f93e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
15 changes: 5 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@

## Unreleased
* Start & Stop Navigation in existing Map
- Removed: `NavigationViewController(for route: Route, dayStyle: Style, routeController: RouteController? = nil, locationManager: NavigationLocationManager? = nil, voiceController: RouteVoiceController? = nil)` use `NavigationViewController(dayStyleURL: URL, nightStyleURL: URL? = nil,directions: Directions = .shared, voiceController: RouteVoiceController = RouteVoiceController())` followed by `startNavigation(with route: Route)` instead.
- To simulate a route, pass a `SimulatedLocationManager` to `startNavigation()` function:
- Removed: `NavigationViewController(for route: Route, dayStyle: Style, routeController: RouteController? = nil, locationManager: NavigationLocationManager? = nil, voiceController: RouteVoiceController? = nil)` use `NavigationViewController(dayStyleURL: URL, nightStyleURL: URL? = nil,directions: Directions = .shared, voiceController: RouteVoiceController = RouteVoiceController())` followed by `startNavigation(with route: Route, animated: Bool)` instead.
- To simulate a route, pass a `SimulatedLocationManager` to `startNavigation()` function:

```swift
let vc = NavigationViewController(dayStyleURL: AppConfig().tileserverStyleUrl)

if Env.current.simulateLocationForTesting {
let simulatedLocationManager = SimulatedLocationManager(route: route)
simulatedLocationManager.speedMultiplier = 5
vc.startNavigation(with: route, locationManager: simulatedLocationManager)
} else {
vc.startNavigation(with: route)
}
let simulatedLocationManager = SimulatedLocationManager(route: route)
simulatedLocationManager.speedMultiplier = 5
vc.startNavigation(with: route, animated: false, locationManager: simulatedLocationManager)
```

## 3.0.0 (Jun 15, 2024)
Expand Down
8 changes: 4 additions & 4 deletions MapboxNavigation/NavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ open class NavigationViewController: UIViewController {

// MARK: - NavigationViewController

public func startNavigation(with route: Route, routeController: RouteController? = nil, locationManager: NavigationLocationManager? = nil) {
public func startNavigation(with route: Route, animated: Bool, routeController: RouteController? = nil, locationManager: NavigationLocationManager? = nil) {
if let locationManager {
self.locationManager = locationManager
}
Expand All @@ -431,7 +431,7 @@ open class NavigationViewController: UIViewController {
}
self.route = route

self.mapViewController.navigationView.showUI(animated: true)
self.mapViewController.navigationView.showUI(animated: animated)
self.mapViewController.destination = route.legs.last?.destination

self.routeController?.usesDefaultUserInterface = true
Expand Down Expand Up @@ -496,8 +496,8 @@ open class NavigationViewController: UIViewController {
let directions = routeController.directions
let route = routeController.routeProgress.route
let navigationViewController = NavigationViewController(dayStyle: DayStyle(demoStyle: ()), nightStyle: NightStyle(demoStyle: ()), directions: directions)
navigationViewController.startNavigation(with: route, routeController: routeController, locationManager: locationManager)
navigationViewController.startNavigation(with: route, animated: true, routeController: routeController, locationManager: locationManager)

window.rootViewController?.topMostViewController()?.present(navigationViewController, animated: true, completion: {
navigationViewController.isUsedInConjunctionWithCarPlayWindow = true
})
Expand Down

0 comments on commit b53f93e

Please sign in to comment.