Skip to content

Commit b91e8da

Browse files
committed
add auto black theme option
Signed-off-by: Philipp Born <[email protected]>
1 parent 2184f1f commit b91e8da

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

Riot/Assets/en.lproj/Vector.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ Tap the + to start adding people.";
767767
"settings_ui_language" = "Language";
768768
"settings_ui_theme" = "Theme";
769769
"settings_ui_theme_auto" = "Auto";
770+
"settings_ui_theme_autoblack" = "Auto (Black)";
770771
"settings_ui_theme_light" = "Light";
771772
"settings_ui_theme_dark" = "Dark";
772773
"settings_ui_theme_black" = "Black";

Riot/Generated/Strings.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7795,6 +7795,10 @@ public class VectorL10n: NSObject {
77957795
public static var settingsUiThemeAuto: String {
77967796
return VectorL10n.tr("Vector", "settings_ui_theme_auto")
77977797
}
7798+
/// Auto (Black)
7799+
public static var settingsUiThemeAutoBlack: String {
7800+
return VectorL10n.tr("Vector", "settings_ui_theme_autoblack")
7801+
}
77987802
/// Black
77997803
public static var settingsUiThemeBlack: String {
78007804
return VectorL10n.tr("Vector", "settings_ui_theme_black")

Riot/Managers/Theme/ThemeService.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ - (void)setTheme:(id<Theme> _Nonnull)theme
7474
}
7575
}
7676

77+
if ([themeId isEqualToString:@"autoblack"])
78+
{
79+
if (@available(iOS 13, *))
80+
{
81+
// Translate "auto" into a theme with UITraitCollection
82+
themeId = ([UITraitCollection currentTraitCollection].userInterfaceStyle == UIUserInterfaceStyleDark) ? @"black" : @"light";
83+
}
84+
else
85+
{
86+
// Translate "auto" into a theme
87+
themeId = UIAccessibilityIsInvertColorsEnabled() ? @"black" : @"light";
88+
}
89+
}
90+
7791
if ([themeId isEqualToString:@"dark"])
7892
{
7993
theme = [DarkTheme new];

Riot/Modules/Settings/SettingsViewController.m

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3887,7 +3887,7 @@ - (void)showThemePicker
38873887
{
38883888
__weak typeof(self) weakSelf = self;
38893889

3890-
__block UIAlertAction *autoAction, *lightAction, *darkAction, *blackAction;
3890+
__block UIAlertAction *autoAction, *autoBlackAction, *lightAction, *darkAction, *blackAction;
38913891
NSString *themePickerMessage;
38923892

38933893
void (^actionBlock)(UIAlertAction *action) = ^(UIAlertAction * action) {
@@ -3913,6 +3913,10 @@ - (void)showThemePicker
39133913
{
39143914
newTheme = @"black";
39153915
}
3916+
else if (action == autoBlackAction)
3917+
{
3918+
newTheme = @"autoblack";
3919+
}
39163920

39173921
NSString *theme = RiotSettings.shared.userInterfaceTheme;
39183922
if (newTheme && ![newTheme isEqualToString:theme])
@@ -3938,6 +3942,11 @@ - (void)showThemePicker
39383942
style:UIAlertActionStyleDefault
39393943
handler:actionBlock];
39403944

3945+
autoBlackAction = [UIAlertAction actionWithTitle:[VectorL10n settingsUiThemeAutoBlack]
3946+
style:UIAlertActionStyleDefault
3947+
handler:actionBlock];
3948+
3949+
39413950
// Explain what is "auto"
39423951
if (@available(iOS 13, *))
39433952
{
@@ -3970,6 +3979,10 @@ - (void)showThemePicker
39703979
{
39713980
[themePicker addAction:autoAction];
39723981
}
3982+
if (autoBlackAction)
3983+
{
3984+
[themePicker addAction:autoBlackAction];
3985+
}
39733986
[themePicker addAction:lightAction];
39743987
[themePicker addAction:darkAction];
39753988
[themePicker addAction:blackAction];

changelog.d/5966.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ThemeService: add a 'Auto (Black)' theme option (@tamcore)

0 commit comments

Comments
 (0)