mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-26 19:34:25 +02:00
Observe changes in system dark mode setting, little refactoring
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user