Browse Source

Dark mode

marinofaggiana 5 years ago
parent
commit
1f7368f711
4 changed files with 33 additions and 4 deletions
  1. 2 0
      iOSClient/AppDelegate.h
  2. 1 1
      iOSClient/AppDelegate.m
  3. 9 3
      iOSClient/Main/CCSplit.m
  4. 21 0
      iOSClient/Settings/CCSettings.m

+ 2 - 0
iOSClient/AppDelegate.h

@@ -130,6 +130,8 @@
 
 @property (nonatomic, strong) NSMutableArray *sessionPendingStatusInUpload;
 
+@property (nonatomic) UIUserInterfaceStyle preferredUserInterfaceStyle API_AVAILABLE(ios(12.0));
+
 // Shares
 @property (nonatomic, strong) NSArray *shares;
 

+ 1 - 1
iOSClient/AppDelegate.m

@@ -1053,8 +1053,8 @@ PKPushRegistry *pushRegistry;
 - (void)settingDarkMode
 {
     [NCBrandColor.sharedInstance setDarkMode];
-    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"changeTheming" object:nil];
     [[NCMainCommon sharedInstance] createImagesThemingColor];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"changeTheming" object:nil];
 }
 
 #pragma --------------------------------------------------------------------------------------------

+ 9 - 3
iOSClient/Main/CCSplit.m

@@ -282,9 +282,15 @@
     
     // detect Dark Mode
     if (@available(iOS 12.0, *)) {
-        UIUserInterfaceStyle interfaceStyle = self.traitCollection.userInterfaceStyle;
-        if (interfaceStyle == UIUserInterfaceStyleDark) {
-        } else {
+        appDelegate.preferredUserInterfaceStyle = self.traitCollection.userInterfaceStyle;
+        if ([CCUtility getDarkModeDetect]) {
+            if (appDelegate.preferredUserInterfaceStyle == UIUserInterfaceStyleDark) {
+                [CCUtility setDarkMode:YES];
+            } else {
+                [CCUtility setDarkMode:NO];
+            }
+                
+            [appDelegate settingDarkMode];
         }
     }
     

+ 21 - 0
iOSClient/Settings/CCSettings.m

@@ -342,8 +342,29 @@
         
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
             [CCUtility setDarkModeDetect:true];
+            
+            // detect Dark Mode
+            if (@available(iOS 12.0, *)) {
+                appDelegate.preferredUserInterfaceStyle = self.traitCollection.userInterfaceStyle;
+                if (appDelegate.preferredUserInterfaceStyle == UIUserInterfaceStyleDark) {
+                    [CCUtility setDarkMode:YES];
+                } else {
+                    [CCUtility setDarkMode:NO];
+                }
+                
+                [appDelegate settingDarkMode];
+            }
+            
         } else {
             [CCUtility setDarkModeDetect:false];
+            
+            [appDelegate settingDarkMode];
+            
+            [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
+            [appDelegate aspectTabBar:self.tabBarController.tabBar hidden:NO];
+            self.tableView.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
+            [self initializeForm];
+            [self reloadForm];
         }
     }
 }