Skip to content

Commit

Permalink
Delay dark mode until nautical sunrise/sunset (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobby Sudekum authored Aug 30, 2017
1 parent 6ab6a07 commit a0decd0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions MapboxNavigation/NavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit a0decd0

Please sign in to comment.