marinofaggiana 4 жил өмнө
parent
commit
b02e2d2f5c

+ 13 - 5
iOSClient/AppDelegate.swift

@@ -147,11 +147,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         
         // Detect Dark mode
         if #available(iOS 13.0, *) {
-            if UITraitCollection.current.userInterfaceStyle == .dark {
-                darkMode = true
-            } else {
-                darkMode = false
-            }
+            setDarkMode(style: UITraitCollection.current.userInterfaceStyle)
         } else {
             darkMode = false
         }
@@ -297,6 +293,18 @@ 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
     

+ 2 - 4
iOSClient/Brand/NCBrand.swift

@@ -235,7 +235,7 @@ class NCBrandColor: NSObject {
     }
     
 #if !EXTENSION
-public func settingThemingColor(account: String, darkMode: Bool) {
+    public func settingThemingColor(account: String, darkMode: Bool) {
         
         let darker: CGFloat = 30    // %
         let lighter: CGFloat = 30   // %
@@ -277,9 +277,7 @@ public func settingThemingColor(account: String, darkMode: Bool) {
             NCBrandColor.shared.brand = NCBrandColor.shared.customer
             NCBrandColor.shared.brandText = NCBrandColor.shared.customerText
         }
-        
-        setDarkMode(darkMode)
-        
+                
         DispatchQueue.main.async {
             self.createImagesThemingColor()
             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeTheming)

+ 6 - 0
iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift

@@ -96,6 +96,12 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
         initializeForm()
     }
     
+    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
+        super.traitCollectionDidChange(previousTraitCollection)
+        
+        appDelegate.setDarkMode(style: traitCollection.userInterfaceStyle)
+    }
+    
     //MARK: XLForm
     
     func initializeForm() {

+ 1 - 10
iOSClient/Main/NCMainTabBar.swift

@@ -48,16 +48,7 @@ class NCMainTabBar: UITabBar {
     override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
         super.traitCollectionDidChange(previousTraitCollection)
         
-        if #available(iOS 13.0, *) {
-            if traitCollection.userInterfaceStyle == .dark {
-                appDelegate.darkMode = true
-            } else {
-                appDelegate.darkMode = false
-            }
-        } else {
-            appDelegate.darkMode = false
-        }
-        NCBrandColor.shared.settingThemingColor(account: appDelegate.account, darkMode: appDelegate.darkMode)
+        appDelegate.setDarkMode(style: traitCollection.userInterfaceStyle)
     }
     
     @objc func changeTheming() {

+ 6 - 0
iOSClient/ScanDocument/ScanCollectionView.swift

@@ -105,6 +105,12 @@ class DragDropViewController: UIViewController {
         labelTitlePDFzone.backgroundColor = .systemBackground
     }
     
+    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
+        super.traitCollectionDidChange(previousTraitCollection)
+        
+        appDelegate.setDarkMode(style: traitCollection.userInterfaceStyle)
+    }
+    
     //MARK: Button Action
 
     @IBAction func cancelAction(sender: UIBarButtonItem) {