diff --git a/Riot/Managers/Theme/ThemeService.m b/Riot/Managers/Theme/ThemeService.m index 06deab82b..d9f2e0fd9 100644 --- a/Riot/Managers/Theme/ThemeService.m +++ b/Riot/Managers/Theme/ThemeService.m @@ -65,6 +65,7 @@ NSString *const kThemeServiceDidChangeThemeNotification = @"kThemeServiceDidChan { if (@available(iOS 13, *)) { + // Translate "auto" into a theme with UITraitCollection themeId = ([UITraitCollection currentTraitCollection].userInterfaceStyle == UIUserInterfaceStyleDark) ? @"dark" : @"light"; } else @@ -104,13 +105,21 @@ NSString *const kThemeServiceDidChangeThemeNotification = @"kThemeServiceDidChan _riotColorIndigo = [[UIColor alloc] initWithRgb:0xBD79CC]; _riotColorOrange = [[UIColor alloc] initWithRgb:0xF8A15F]; - // Observe "Invert Colours" settings changes (available since iOS 11) - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accessibilityInvertColorsStatusDidChange) name:UIAccessibilityInvertColorsStatusDidChangeNotification object:nil]; + if (@available(iOS 13, *)) + { + // Observe application did become active for iOS appearance setting changes + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil]; + } + else + { + // Observe "Invert Colours" settings changes (available since iOS 11) + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accessibilityInvertColorsStatusDidChange) name:UIAccessibilityInvertColorsStatusDidChangeNotification object:nil]; + } } return self; } -- (void)accessibilityInvertColorsStatusDidChange +- (void)refreshThemeIfAuto { // Refresh the theme only for "auto" if ([self.themeId isEqualToString:@"auto"]) @@ -119,6 +128,16 @@ NSString *const kThemeServiceDidChangeThemeNotification = @"kThemeServiceDidChan } } +- (void)accessibilityInvertColorsStatusDidChange +{ + [self refreshThemeIfAuto]; +} + +- (void)applicationDidBecomeActive +{ + [self refreshThemeIfAuto]; +} + - (void)updateAppearance { [UIScrollView appearance].indicatorStyle = self.theme.scrollBarStyle;