marinofaggiana 5 vuotta sitten
vanhempi
commit
2e7f55d1f1

+ 16 - 2
iOSClient/Settings/CCSettings.m

@@ -132,7 +132,7 @@
     
     // Dark Mode
     if (@available(iOS 13.0, *)) {
-        row = [XLFormRowDescriptor formRowDescriptorWithTag:@"darkModeAutomatic" rowType:XLFormRowDescriptorTypeBooleanSwitch title:[NSString stringWithFormat:@"%@ (beta)", NSLocalizedString(@"_dark_mode_automatic_", nil)]];
+        row = [XLFormRowDescriptor formRowDescriptorWithTag:@"darkModeDetect" rowType:XLFormRowDescriptorTypeBooleanSwitch title:[NSString stringWithFormat:@"%@ (beta)", NSLocalizedString(@"_dark_mode_detect_", nil)]];
         row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
         [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"themeLightDark"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
@@ -145,6 +145,9 @@
     [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"themeLightDark"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
     [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
+    if (@available(iOS 13.0, *)) {
+        row.hidden = [NSString stringWithFormat:@"$%@==1", @"darkModeDetect"];
+    }
     [section addFormRow:row];
     
     // Section : E2EEncryption --------------------------------------------------------------
@@ -244,6 +247,7 @@
     XLFormRowDescriptor *rowOnlyLockDir = [self.form formRowWithTag:@"onlylockdir"];
     XLFormRowDescriptor *rowFavoriteOffline = [self.form formRowWithTag:@"favoriteoffline"];
     XLFormRowDescriptor *rowDarkMode = [self.form formRowWithTag:@"darkMode"];
+    XLFormRowDescriptor *rowDarkModeDetect = [self.form formRowWithTag:@"darkModeDetect"];
 
     // ------------------------------------------------------------------
     
@@ -259,7 +263,8 @@
     if ([CCUtility getOnlyLockDir]) [rowOnlyLockDir setValue:@1]; else [rowOnlyLockDir setValue:@0];
     if ([CCUtility getFavoriteOffline]) [rowFavoriteOffline setValue:@1]; else [rowFavoriteOffline setValue:@0];
     if ([CCUtility getDarkMode]) [rowDarkMode setValue:@1]; else [rowDarkMode setValue:@0];
-    
+    if ([CCUtility getDarkModeDetect]) [rowDarkModeDetect setValue:@1]; else [rowDarkModeDetect setValue:@0];
+
     // -----------------------------------------------------------------
     
     [self.tableView reloadData];
@@ -333,6 +338,15 @@
         [self initializeForm];
         [self reloadForm];
     }
+    
+    if ([rowDescriptor.tag isEqualToString:@"darkModeDetect"]) {
+        
+        if ([[rowDescriptor.value valueData] boolValue] == YES) {
+            [CCUtility setDarkModeDetect:true];
+        } else {
+            [CCUtility setDarkModeDetect:false];
+        }
+    }
 }
 
 - (void)changeSimplyPassword

+ 1 - 1
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -107,7 +107,7 @@
 "_sharing_"                 = "Sharing";
 "_details_"                 = "Details";
 "_dark_mode_"               = "Dark mode";
-"_dark_mode_automatic_"     = "Use ";
+"_dark_mode_detect_"        = "Detect iOS dark mode";
 "_screen_"                  = "Screen";
 "_wipe_account_"            = "Account wiped from server";
 "_appconfig_view_title_"    = "Account configuration in progress...";

+ 3 - 0
iOSClient/Utility/CCUtility.h

@@ -171,6 +171,9 @@
 + (BOOL)getDarkMode;
 + (void)setDarkMode:(BOOL)disable;
 
++ (BOOL)getDarkModeDetect;
++ (void)setDarkModeDetect:(BOOL)disable;
+
 // ===== Varius =====
 
 + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;

+ 11 - 0
iOSClient/Utility/CCUtility.m

@@ -668,6 +668,17 @@
     [UICKeyChainStore setString:sDisable forKey:@"darkMode" service:k_serviceShareKeyChain];
 }
 
++ (BOOL)getDarkModeDetect
+{
+    return [[UICKeyChainStore stringForKey:@"darkModeDetect" service:k_serviceShareKeyChain] boolValue];
+}
+
++ (void)setDarkModeDetect:(BOOL)disable
+{
+    NSString *sDisable = (disable) ? @"true" : @"false";
+    [UICKeyChainStore setString:sDisable forKey:@"darkModeDetect" service:k_serviceShareKeyChain];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Various =====
 #pragma --------------------------------------------------------------------------------------------