From a0decd0aa45458c10778d77f3dd1cb137aa751ec Mon Sep 17 00:00:00 2001 From: Bobby Sudekum Date: Wed, 30 Aug 2017 16:34:06 -0400 Subject: [PATCH] Delay dark mode until nautical sunrise/sunset (#557) --- MapboxNavigation/NavigationViewController.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MapboxNavigation/NavigationViewController.swift b/MapboxNavigation/NavigationViewController.swift index 2dfe6d81119..2aa5bd05034 100644 --- a/MapboxNavigation/NavigationViewController.swift +++ b/MapboxNavigation/NavigationViewController.swift @@ -264,11 +264,15 @@ public class NavigationViewController: NavigationPulleyViewController, RouteMapV guard automaticallyAdjustsStyleForTimeOfDay else { return .dayStyle } guard let location = routeController.location, - let solar = Solar(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude) else { + let solar = Solar(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude), + let sunrise = solar.civilSunrise, let sunset = solar.civilSunset else { return .dayStyle } - return solar.isDaytime ? .dayStyle : .nightStyle + let isAfterSunrise = solar.date > sunrise + let isBeforeSunset = solar.date < sunset + + return isAfterSunrise && isBeforeSunset ? .dayStyle : .nightStyle } var tableViewController: RouteTableViewController?