forked from organicmaps/organicmaps
[themes] Review fixes.
This commit is contained in:
parent
9b17059306
commit
1029dd2e11
2 changed files with 23 additions and 17 deletions
|
@ -32,14 +32,17 @@
|
|||
+ (void)setTheme:(MWMTheme)theme
|
||||
{
|
||||
auto & f = GetFramework();
|
||||
auto style = f.GetMapStyle();
|
||||
MapStyle newStyle = MapStyleClear;
|
||||
switch (theme)
|
||||
{
|
||||
case MWMThemeDay: break;
|
||||
case MWMThemeNight: newStyle = MapStyleDark; break;
|
||||
case MWMThemeAuto: NSAssert(NO, @"Invalid theme");
|
||||
}
|
||||
|
||||
auto const style = f.GetMapStyle();
|
||||
auto const newStyle = ^MapStyle(MWMTheme theme) {
|
||||
switch (theme)
|
||||
{
|
||||
case MWMThemeDay: return MapStyleClear;
|
||||
case MWMThemeNight: return MapStyleDark;
|
||||
case MWMThemeAuto: NSAssert(NO, @"Invalid theme"); return MapStyleClear;
|
||||
}
|
||||
}(theme);
|
||||
|
||||
if (style != newStyle)
|
||||
f.SetMapStyle(newStyle);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@objc(MWMThemeManager)
|
||||
final class ThemeManager: NSObject {
|
||||
|
||||
private static let autoUpdatesInterval: TimeInterval = 30 * 60;
|
||||
private static let autoUpdatesInterval: TimeInterval = 30 * 60 // 30 minutes in seconds
|
||||
|
||||
private static let instance = ThemeManager()
|
||||
private weak var timer: Timer?
|
||||
|
@ -9,7 +9,7 @@ final class ThemeManager: NSObject {
|
|||
private override init() { super.init() }
|
||||
|
||||
private func update(theme: MWMTheme) {
|
||||
let actualTheme = { theme -> MWMTheme in
|
||||
let actualTheme: MWMTheme = { theme in
|
||||
guard theme == .auto else { return theme }
|
||||
guard MWMRouter.isRoutingActive() else { return .day }
|
||||
switch MWMFrameworkHelper.daytime() {
|
||||
|
@ -17,14 +17,17 @@ final class ThemeManager: NSObject {
|
|||
case .night: return .night
|
||||
}
|
||||
}(theme)
|
||||
MWMFrameworkHelper.setTheme(actualTheme)
|
||||
|
||||
let nightMode = UIColor.isNightMode()
|
||||
var newNightMode = false
|
||||
switch actualTheme {
|
||||
case .day: break
|
||||
case .night: newNightMode = true
|
||||
case .auto: assert(false)
|
||||
}
|
||||
let newNightMode: Bool = { theme in
|
||||
switch theme {
|
||||
case .day: return false
|
||||
case .night: return true
|
||||
case .auto: assert(false); return false
|
||||
}
|
||||
}(actualTheme)
|
||||
|
||||
MWMFrameworkHelper.setTheme(actualTheme)
|
||||
if nightMode != newNightMode {
|
||||
UIColor.setNightMode(newNightMode)
|
||||
(UIViewController.topViewController() as! MWMController).mwm_refreshUI()
|
||||
|
|
Loading…
Add table
Reference in a new issue