marinofaggiana 4 years ago
parent
commit
acac6809a8

+ 3 - 3
iOSClient/Account Request/NCAccountRequest.swift

@@ -85,8 +85,8 @@ class NCAccountRequest: UIViewController {
 
     @objc func changeTheming() {
         
-        view.backgroundColor = NCBrandColor.shared.backgroundForm
-        tableView.backgroundColor = NCBrandColor.shared.backgroundForm
+        view.backgroundColor = NCBrandColor.shared.backgroundView
+        tableView.backgroundColor = NCBrandColor.shared.backgroundView
         tableView.reloadData()
     }
     
@@ -185,7 +185,7 @@ extension NCAccountRequest: UITableViewDataSource {
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
                
         let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
-        cell.backgroundColor = NCBrandColor.shared.backgroundForm
+        cell.backgroundColor = NCBrandColor.shared.backgroundView
        
         let avatarImage = cell.viewWithTag(10) as? UIImageView
         let userLabel = cell.viewWithTag(20) as? UILabel

+ 17 - 14
iOSClient/AppDelegate.swift

@@ -55,7 +55,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     var listOfflineVC: [String:NCOffline] = [:]
     var listProgress: [String:NCGlobal.progressType] = [:]
     
-    @objc var darkMode: Bool = false
     var disableSharesView: Bool = false
     var documentPickerViewController: NCDocumentPickerViewController?
     var networkingProcessUpload: NCNetworkingProcessUpload?
@@ -63,6 +62,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     var pasteboardOcIds: [String] = []
     var shares: [tableShare] = []
     var timerErrorNetworking: Timer?
+    
+    private var dark: Bool = false
+    var darkMode: Bool {
+        get {
+            return self.dark
+        }
+        set(value) {
+            self.dark = value
+            NCBrandColor.shared.setDarkMode(value)
+            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeTheming)
+        }
+    }
 
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
         
@@ -76,7 +87,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
         
         if #available(iOS 13.0, *) {
-            setDarkMode(style: UITraitCollection.current.userInterfaceStyle)
+            if UITraitCollection.current.userInterfaceStyle == .dark {
+                darkMode = true
+            } else {
+                darkMode = false
+            }            
         } else {
             darkMode = false
         }
@@ -292,18 +307,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         //[fileProviderDomain removeAllDomains];
         //[fileProviderDomain registerDomains];
     }
-    
-    @objc func setDarkMode(style: UIUserInterfaceStyle) {
-        
-        if style == .dark {
-            darkMode = true
-        } else {
-            darkMode = false
-        }
-        
-        NCBrandColor.shared.setDarkMode(darkMode)
-        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeTheming)
-    }
   
     // MARK: - Background Task
     

+ 0 - 1
iOSClient/Main/NCMainNavigationController.swift

@@ -38,7 +38,6 @@ class NCMainNavigationController: UINavigationController {
             appDelegate.darkMode = false
         }
         
-        NCBrandColor.shared.setDarkMode(appDelegate.darkMode)
         changeTheming()
     }
 

+ 5 - 2
iOSClient/Main/NCMainTabBar.swift

@@ -48,14 +48,17 @@ class NCMainTabBar: UITabBar {
             appDelegate.darkMode = false
         }
         
-        NCBrandColor.shared.setDarkMode(appDelegate.darkMode)
         changeTheming()
     }
     
     override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
         super.traitCollectionDidChange(previousTraitCollection)
         
-        appDelegate.setDarkMode(style: traitCollection.userInterfaceStyle)
+        if traitCollection.userInterfaceStyle == .dark {
+            appDelegate.darkMode = true
+        } else {
+            appDelegate.darkMode = false
+        }
     }
     
     @objc func changeTheming() {

+ 1 - 1
iOSClient/Rename file/NCRenameFile.swift

@@ -133,7 +133,7 @@ class NCRenameFile: UIViewController, UITextFieldDelegate {
     // MARK: - NotificationCenter
 
     @objc func changeTheming() {
-        view.backgroundColor = NCBrandColor.shared.backgroundForm
+        view.backgroundColor = NCBrandColor.shared.backgroundView
     }
     
     // MARK: - Action

+ 5 - 1
iOSClient/RichWorkspace/NCViewerRichWorkspace.swift

@@ -73,7 +73,11 @@ import MarkdownKit
     override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
         super.traitCollectionDidChange(previousTraitCollection)
         
-        appDelegate.setDarkMode(style: traitCollection.userInterfaceStyle)
+        if traitCollection.userInterfaceStyle == .dark {
+            appDelegate.darkMode = true
+        } else {
+            appDelegate.darkMode = false
+        }
     }
     
     public func presentationControllerWillDismiss(_ presentationController: UIPresentationController) {