diff --git a/iphone/Maps/Common/MWMTypes.h b/iphone/Maps/Common/MWMTypes.h index d63ee2e7e3..37e6162ec9 100644 --- a/iphone/Maps/Common/MWMTypes.h +++ b/iphone/Maps/Common/MWMTypes.h @@ -12,4 +12,10 @@ typedef NS_ENUM(NSUInteger, MWMRouterType) { MWMRouterTypeTaxi }; -typedef NS_ENUM(NSUInteger, MWMTheme) { MWMThemeDay, MWMThemeNight, MWMThemeAuto }; +typedef NS_ENUM(NSUInteger, MWMTheme) { + MWMThemeDay, + MWMThemeNight, + MWMThemeVehicleDay, + MWMThemeVehicleNight, + MWMThemeAuto +}; diff --git a/iphone/Maps/Core/Framework/MWMFrameworkHelper.mm b/iphone/Maps/Core/Framework/MWMFrameworkHelper.mm index 7c6cf06fe9..3ef43d7ae5 100644 --- a/iphone/Maps/Core/Framework/MWMFrameworkHelper.mm +++ b/iphone/Maps/Core/Framework/MWMFrameworkHelper.mm @@ -38,7 +38,9 @@ switch (theme) { case MWMThemeDay: return MapStyleClear; + case MWMThemeVehicleDay: return MapStyleVehicleClear; case MWMThemeNight: return MapStyleDark; + case MWMThemeVehicleNight: return MapStyleVehicleDark; case MWMThemeAuto: NSAssert(NO, @"Invalid theme"); return MapStyleClear; } }(theme); @@ -51,10 +53,7 @@ { CLLocation * lastLocation = [MWMLocationManager lastLocation]; if (!lastLocation) - { - NSAssert(false, @"Last location is not available"); return MWMDayTimeDay; - } auto const coord = lastLocation.coordinate; auto const timeUtc = static_cast(NSDate.date.timeIntervalSince1970); auto const dayTime = GetDayTime(timeUtc, coord.latitude, coord.longitude); diff --git a/iphone/Maps/UI/Appearance/ThemeManager.swift b/iphone/Maps/UI/Appearance/ThemeManager.swift index a97fcd66f5..2db937c358 100644 --- a/iphone/Maps/UI/Appearance/ThemeManager.swift +++ b/iphone/Maps/UI/Appearance/ThemeManager.swift @@ -10,19 +10,28 @@ final class ThemeManager: NSObject { private func update(theme: MWMTheme) { let actualTheme: MWMTheme = { theme in - guard theme == .auto else { return theme } - guard MWMRouter.isRoutingActive() else { return .day } - switch MWMFrameworkHelper.daytime() { - case .day: return .day - case .night: return .night + let isRoutingActive = MWMRouter.isRoutingActive() + switch theme { + case .day: fallthrough + case .vehicleDay: return isRoutingActive ? .vehicleDay : .day + case .night: fallthrough + case .vehicleNight: return isRoutingActive ? .vehicleNight : .night + case .auto: + guard isRoutingActive else { return .day } + switch MWMFrameworkHelper.daytime() { + case .day: return .vehicleDay + case .night: return .vehicleNight + } } }(theme) let nightMode = UIColor.isNightMode() let newNightMode: Bool = { theme in switch theme { - case .day: return false - case .night: return true + case .day: fallthrough + case .vehicleDay: return false + case .night: fallthrough + case .vehicleNight: return true case .auto: assert(false); return false } }(actualTheme) diff --git a/iphone/Maps/UI/Settings/MWMNightModeController.mm b/iphone/Maps/UI/Settings/MWMNightModeController.mm index 17a8819af8..e9d31bd50d 100644 --- a/iphone/Maps/UI/Settings/MWMNightModeController.mm +++ b/iphone/Maps/UI/Settings/MWMNightModeController.mm @@ -24,7 +24,9 @@ SettingsTableViewSelectableCell * selectedCell = nil; switch ([MWMSettings theme]) { + case MWMThemeVehicleDay: NSAssert(false, @"Invalid case"); case MWMThemeDay: selectedCell = self.off; break; + case MWMThemeVehicleNight: NSAssert(false, @"Invalid case"); case MWMThemeNight: selectedCell = self.on; break; case MWMThemeAuto: selectedCell = self.autoSwitch; break; } diff --git a/iphone/Maps/UI/Settings/MWMSettingsViewController.mm b/iphone/Maps/UI/Settings/MWMSettingsViewController.mm index 9fedc658a7..d047b21d62 100644 --- a/iphone/Maps/UI/Settings/MWMSettingsViewController.mm +++ b/iphone/Maps/UI/Settings/MWMSettingsViewController.mm @@ -144,7 +144,9 @@ extern NSString * const kAlohalyticsTapEventKey; NSString * nightMode = nil; switch ([MWMSettings theme]) { + case MWMThemeVehicleDay: NSAssert(false, @"Invalid case"); case MWMThemeDay: nightMode = L(@"pref_map_style_default"); break; + case MWMThemeVehicleNight: NSAssert(false, @"Invalid case"); case MWMThemeNight: nightMode = L(@"pref_map_style_night"); break; case MWMThemeAuto: nightMode = L(@"pref_map_style_auto"); break; }