forked from organicmaps/organicmaps
[MAPSME-4211] [ios] Added vehicle themes support.
This commit is contained in:
parent
1c91ca0b92
commit
0485d4a10a
5 changed files with 29 additions and 11 deletions
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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<time_t>(NSDate.date.timeIntervalSince1970);
|
||||
auto const dayTime = GetDayTime(timeUtc, coord.latitude, coord.longitude);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue