From b0c1397a7e462476b2fb2e22895545493a041601 Mon Sep 17 00:00:00 2001 From: Patrick Kladek Date: Mon, 1 Jul 2024 16:29:31 +0200 Subject: [PATCH 1/4] prevent code from running again after setting the same property again --- MapboxNavigation/NavigationViewController.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MapboxNavigation/NavigationViewController.swift b/MapboxNavigation/NavigationViewController.swift index f91423ca..5b0acf53 100644 --- a/MapboxNavigation/NavigationViewController.swift +++ b/MapboxNavigation/NavigationViewController.swift @@ -214,6 +214,8 @@ open class NavigationViewController: UIViewController { var currentStatusBarStyle: UIStatusBarStyle = .default { didSet { + guard oldValue != self.currentStatusBarStyle else { return } + self.mapViewController.instructionsBannerView.backgroundColor = InstructionsBannerView.appearance().backgroundColor self.mapViewController.instructionsBannerContentView.backgroundColor = InstructionsBannerContentView.appearance().backgroundColor } @@ -228,6 +230,8 @@ open class NavigationViewController: UIViewController { */ public var route: Route? { didSet { + guard oldValue != self.route else { return } + if let route { if self.routeController == nil { let routeController = RouteController(along: route, directions: self.directions, locationManager: self.locationManager) @@ -283,6 +287,8 @@ open class NavigationViewController: UIViewController { */ public var routeController: RouteController? { didSet { + guard oldValue != self.routeController else { return } + self.mapViewController.routeController = self.routeController } } @@ -313,6 +319,8 @@ open class NavigationViewController: UIViewController { */ public var automaticallyAdjustsStyleForTimeOfDay = true { didSet { + guard oldValue != self.automaticallyAdjustsStyleForTimeOfDay else { return } + self.styleManager.automaticallyAdjustsStyleForTimeOfDay = self.automaticallyAdjustsStyleForTimeOfDay } } From 41116711a2e54e108422bd4f8080d723e7a8625f Mon Sep 17 00:00:00 2001 From: Patrick Kladek Date: Mon, 1 Jul 2024 17:07:34 +0200 Subject: [PATCH 2/4] reset LocationManager on endNavigation --- MapboxNavigation/NavigationViewController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MapboxNavigation/NavigationViewController.swift b/MapboxNavigation/NavigationViewController.swift index 5b0acf53..76a0fe22 100644 --- a/MapboxNavigation/NavigationViewController.swift +++ b/MapboxNavigation/NavigationViewController.swift @@ -475,6 +475,7 @@ open class NavigationViewController: UIViewController { self.voiceController = nil self.route = nil + self.locationManager = NavigationLocationManager() self.mapViewController.navigationView.hideUI(animated: animated) self.mapView.tracksUserCourse = false From 427721ac9163c556eee7260598a0dc46a7019df6 Mon Sep 17 00:00:00 2001 From: Patrick Kladek Date: Mon, 1 Jul 2024 17:32:03 +0200 Subject: [PATCH 3/4] hide endOfRoute UI on dismiss button tap --- MapboxNavigation/NavigationViewController.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MapboxNavigation/NavigationViewController.swift b/MapboxNavigation/NavigationViewController.swift index 76a0fe22..62703df3 100644 --- a/MapboxNavigation/NavigationViewController.swift +++ b/MapboxNavigation/NavigationViewController.swift @@ -658,7 +658,9 @@ extension NavigationViewController: RouteControllerDelegate { guard let self else { return } - self.delegate?.navigationViewControllerDidFinishRouting?(self) + self.mapViewController.hideEndOfRoute { _ in + self.delegate?.navigationViewControllerDidFinishRouting?(self) + } }) } return advancesToNextLeg From 4030f4ef98fa617845361eb7720b54494e7371ea Mon Sep 17 00:00:00 2001 From: Patrick Kladek Date: Fri, 12 Jul 2024 19:34:14 +0200 Subject: [PATCH 4/4] pass locationManager per route and not per VC --- Example/example/SceneDelegate.swift | 2 +- MapboxNavigation/NavigationViewController.swift | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Example/example/SceneDelegate.swift b/Example/example/SceneDelegate.swift index 39603c5f..7cc88fab 100644 --- a/Example/example/SceneDelegate.swift +++ b/Example/example/SceneDelegate.swift @@ -94,7 +94,7 @@ private extension SceneDelegate { let simulatedLocationManager = SimulatedLocationManager(route: route) simulatedLocationManager.speedMultiplier = 2 - self.viewController.startNavigation(with: route, locationManager: simulatedLocationManager) + self.viewController.startNavigation(with: route, animated: true, locationManager: simulatedLocationManager) } } diff --git a/MapboxNavigation/NavigationViewController.swift b/MapboxNavigation/NavigationViewController.swift index 62703df3..3195d941 100644 --- a/MapboxNavigation/NavigationViewController.swift +++ b/MapboxNavigation/NavigationViewController.swift @@ -435,10 +435,8 @@ open class NavigationViewController: UIViewController { // MARK: - NavigationViewController - public func startNavigation(with route: Route, animated: Bool, routeController: RouteController? = nil, locationManager: NavigationLocationManager? = nil) { - if let locationManager { - self.locationManager = locationManager - } + public func startNavigation(with route: Route, animated: Bool, routeController: RouteController? = nil, locationManager: NavigationLocationManager = NavigationLocationManager()) { + self.locationManager = locationManager if let routeController { self.routeController = routeController }