diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a1d5a15b8..4ab7a13dc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changes to the Mapbox Navigation SDK for iOS +## master + +`StyleManagerDelegate.locationFor(styleManager:)` has been renamed to `StyleManagerDelegate.location(for:)` ([#1724](https://github.com/mapbox/mapbox-navigation-ios/pull/1724)) + ## v0.21.0 (September 17, 2018) ### User interface diff --git a/MapboxNavigation/CarPlayMapViewController.swift b/MapboxNavigation/CarPlayMapViewController.swift index 457b58282b..90def749fa 100644 --- a/MapboxNavigation/CarPlayMapViewController.swift +++ b/MapboxNavigation/CarPlayMapViewController.swift @@ -122,7 +122,7 @@ class CarPlayMapViewController: UIViewController, MGLMapViewDelegate { @available(iOS 12.0, *) extension CarPlayMapViewController: StyleManagerDelegate { - func locationFor(styleManager: StyleManager) -> CLLocation? { + func location(for styleManager: StyleManager) -> CLLocation? { return mapView.userLocationForCourseTracking ?? mapView.userLocation?.location ?? coarseLocationManager.location } diff --git a/MapboxNavigation/CarPlayNavigationViewController.swift b/MapboxNavigation/CarPlayNavigationViewController.swift index be0fde9b01..0df5ba1380 100644 --- a/MapboxNavigation/CarPlayNavigationViewController.swift +++ b/MapboxNavigation/CarPlayNavigationViewController.swift @@ -376,7 +376,7 @@ public class CarPlayNavigationViewController: UIViewController, MGLMapViewDelega @available(iOS 12.0, *) extension CarPlayNavigationViewController: StyleManagerDelegate { - public func locationFor(styleManager: StyleManager) -> CLLocation? { + public func location(for styleManager: StyleManager) -> CLLocation? { return routeController.locationManager.location } diff --git a/MapboxNavigation/NavigationViewController.swift b/MapboxNavigation/NavigationViewController.swift index 0b309c024e..8df6f71580 100644 --- a/MapboxNavigation/NavigationViewController.swift +++ b/MapboxNavigation/NavigationViewController.swift @@ -685,7 +685,7 @@ extension NavigationViewController: TunnelIntersectionManagerDelegate { extension NavigationViewController: StyleManagerDelegate { - public func locationFor(styleManager: StyleManager) -> CLLocation? { + public func location(for styleManager: StyleManager) -> CLLocation? { if let location = routeController.location { return location } else if let firstCoord = routeController.routeProgress.route.coordinates?.first { diff --git a/MapboxNavigation/StyleManager.swift b/MapboxNavigation/StyleManager.swift index b9b282ec0d..562ce7347d 100644 --- a/MapboxNavigation/StyleManager.swift +++ b/MapboxNavigation/StyleManager.swift @@ -9,7 +9,8 @@ public protocol StyleManagerDelegate: NSObjectProtocol { /** Asks the delegate for a location to use when calculating sunset and sunrise. */ - @objc func locationFor(styleManager: StyleManager) -> CLLocation? + @objc(locationForStyleManager:) + func location(for styleManager: StyleManager) -> CLLocation? /** Informs the delegate that a style was applied. @@ -95,7 +96,7 @@ open class StyleManager: NSObject { NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(timeOfDayChanged), object: nil) guard automaticallyAdjustsStyleForTimeOfDay && styles.count > 1 else { return } - guard let location = delegate?.locationFor(styleManager: self) else { return } + guard let location = delegate?.location(for:self) else { return } guard let solar = Solar(date: date, coordinate: location.coordinate), let sunrise = solar.sunrise, @@ -137,7 +138,7 @@ open class StyleManager: NSObject { } func applyStyle() { - guard let location = delegate?.locationFor(styleManager: self) else { + guard let location = delegate?.location(for: self) else { // We can't calculate sunset or sunrise w/o a location so just apply the first style if let style = styles.first, currentStyleType != style.styleType { currentStyleType = style.styleType @@ -172,7 +173,7 @@ open class StyleManager: NSObject { } func forceRefreshAppearanceIfNeeded() { - guard let location = delegate?.locationFor(styleManager: self) else { return } + guard let location = delegate?.location(for: self) else { return } let styleTypeForLocation = styleType(for: location) diff --git a/MapboxNavigationTests/NavigationViewControllerTests.swift b/MapboxNavigationTests/NavigationViewControllerTests.swift index 8fd9786c7c..8790b99024 100644 --- a/MapboxNavigationTests/NavigationViewControllerTests.swift +++ b/MapboxNavigationTests/NavigationViewControllerTests.swift @@ -215,7 +215,7 @@ class NavigationViewControllerTests: XCTestCase { } extension NavigationViewControllerTests: NavigationViewControllerDelegate, StyleManagerDelegate { - func locationFor(styleManager: StyleManager) -> CLLocation? { + func location(for styleManager: StyleManager) -> CLLocation? { return dependencies.poi.first! } diff --git a/MapboxNavigationTests/StyleManagerTests.swift b/MapboxNavigationTests/StyleManagerTests.swift index 72009ee244..49c62d0be6 100644 --- a/MapboxNavigationTests/StyleManagerTests.swift +++ b/MapboxNavigationTests/StyleManagerTests.swift @@ -129,7 +129,7 @@ extension StyleManagerTests: StyleManagerDelegate { func styleManagerDidRefreshAppearance(_ styleManager: StyleManager) { } func styleManager(_ styleManager: StyleManager, didApply style: Style) { } - func locationFor(styleManager: StyleManager) -> CLLocation? { + func location(for styleManager: StyleManager) -> CLLocation? { return location } }