marinofaggiana 3 years ago
parent
commit
981cc0bf70

+ 7 - 5
iOSClient/BackgroundImageColor/NCBackgroundImageColor.swift

@@ -29,9 +29,7 @@ class NCBackgroundImageColor: UIViewController {
     @IBOutlet weak var titleLabel: UILabel!
     @IBOutlet weak var chromaColorPickerView: UIView!
     
-    @IBOutlet weak var defaultButton: UIButton!
-
-    
+    @IBOutlet weak var defaultButton: UIButton!    
     @IBOutlet weak var cancelButton: UIButton!
     @IBOutlet weak var okButton: UIButton!
     
@@ -88,11 +86,15 @@ class NCBackgroundImageColor: UIViewController {
     
     @IBAction func okAction(_ sender: Any) {
         
+        if traitCollection.userInterfaceStyle == .dark {
+            
+        }
+        
         if let collectionViewCommon = collectionViewCommon {
             if colorHandle?.color == defaultColor {
-                NCUtility.shared.setBackgroundColorForView(key: collectionViewCommon.layoutKey, serverUrl: collectionViewCommon.serverUrl, colorBackground: "")
+                NCUtility.shared.setBackgroundColorForView(key: collectionViewCommon.layoutKey, serverUrl: collectionViewCommon.serverUrl, colorBackground: "", colorDarkBackground: "")
             } else {
-                NCUtility.shared.setBackgroundColorForView(key: collectionViewCommon.layoutKey, serverUrl: collectionViewCommon.serverUrl, colorBackground: colorHexString)
+                //NCUtility.shared.setBackgroundColorForView(key: collectionViewCommon.layoutKey, serverUrl: collectionViewCommon.serverUrl, colorBackground: colorHexString)
             }
         }
         collectionViewCommon?.setLayout()

+ 13 - 3
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -601,6 +601,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             collectionView?.collectionViewLayout = gridLayout
         }
         
+        // IMAGE BACKGROUND
         if layoutForView?.imageBackgroud != "" {
             let imagePath = CCUtility.getDirectoryGroup().appendingPathComponent(NCGlobal.shared.appBackground).path + "/" + layoutForView!.imageBackgroud
             do {
@@ -616,10 +617,19 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             collectionView.backgroundView = nil
         }
         
-        if layoutForView?.colorBackground != "" {
-            collectionView.backgroundColor = UIColor.init(hex: layoutForView?.colorBackground ?? "")
+        // COLOR BACKGROUND
+        if traitCollection.userInterfaceStyle == .dark {
+            if layoutForView?.colorDarkBackground != "" {
+                collectionView.backgroundColor = UIColor.init(hex: layoutForView?.colorDarkBackground ?? "")
+            } else {
+                collectionView.backgroundColor = defaultBackgroundColor
+            }
         } else {
-            collectionView.backgroundColor = defaultBackgroundColor
+            if layoutForView?.colorBackground != "" {
+                collectionView.backgroundColor = UIColor.init(hex: layoutForView?.colorBackground ?? "")
+            } else {
+                collectionView.backgroundColor = defaultBackgroundColor
+            }
         }
     }
 

+ 1 - 0
iOSClient/NCGlobal.swift

@@ -50,6 +50,7 @@ class NCGlobal: NSObject {
         var imageBackgroud: String
         var imageBackgroudContentMode: String
         var colorBackground: String
+        var colorDarkBackground: String
     }
     
     // Directory on Group

+ 7 - 4
iOSClient/Utility/NCUtility.swift

@@ -40,7 +40,7 @@ class NCUtility: NSObject {
 
     func setLayoutForView(key: String, serverUrl: String, layoutForView: NCGlobal.layoutForViewType) {
         
-        let string =  layoutForView.layout + "|" + layoutForView.sort + "|" + "\(layoutForView.ascending)" + "|" + layoutForView.groupBy + "|" + "\(layoutForView.directoryOnTop)" + "|" + layoutForView.titleButtonHeader + "|" + "\(layoutForView.itemForLine)" + "|" + layoutForView.imageBackgroud + "|" + layoutForView.imageBackgroudContentMode + "|" + layoutForView.colorBackground
+        let string =  layoutForView.layout + "|" + layoutForView.sort + "|" + "\(layoutForView.ascending)" + "|" + layoutForView.groupBy + "|" + "\(layoutForView.directoryOnTop)" + "|" + layoutForView.titleButtonHeader + "|" + "\(layoutForView.itemForLine)" + "|" + layoutForView.imageBackgroud + "|" + layoutForView.imageBackgroudContentMode + "|" + layoutForView.colorBackground + "|" + layoutForView.colorDarkBackground
         var keyStore = key
         
         if serverUrl != "" {
@@ -60,11 +60,12 @@ class NCUtility: NSObject {
         }
     }
     
-    func setBackgroundColorForView(key: String, serverUrl: String, colorBackground: String) {
+    func setBackgroundColorForView(key: String, serverUrl: String, colorBackground: String, colorDarkBackground: String) {
         
         var layoutForView: NCGlobal.layoutForViewType = NCUtility.shared.getLayoutForView(key: key, serverUrl: serverUrl)
         
         layoutForView.colorBackground = colorBackground
+        layoutForView.colorDarkBackground = colorDarkBackground
         
         setLayoutForView(key: key, serverUrl: serverUrl, layoutForView: layoutForView)
     }
@@ -82,7 +83,7 @@ class NCUtility: NSObject {
     func getLayoutForView(key: String, serverUrl: String, sort: String = "fileName", ascending: Bool = true, titleButtonHeader: String = "_sorted_by_name_a_z_") -> (NCGlobal.layoutForViewType) {
         
         var keyStore = key
-        var layoutForView: NCGlobal.layoutForViewType = NCGlobal.layoutForViewType(layout: NCGlobal.shared.layoutList, sort: sort, ascending: ascending, groupBy: "none", directoryOnTop: true, titleButtonHeader: titleButtonHeader, itemForLine: 3, imageBackgroud: "", imageBackgroudContentMode: "", colorBackground: "")
+        var layoutForView: NCGlobal.layoutForViewType = NCGlobal.layoutForViewType(layout: NCGlobal.shared.layoutList, sort: sort, ascending: ascending, groupBy: "none", directoryOnTop: true, titleButtonHeader: titleButtonHeader, itemForLine: 3, imageBackgroud: "", imageBackgroudContentMode: "", colorBackground: "", colorDarkBackground: "")
         
         if serverUrl != "" {
             keyStore = serverUrl
@@ -95,6 +96,7 @@ class NCUtility: NSObject {
 
         let array = string.components(separatedBy: "|")
         if array.count >= 7 {
+            // version 1
             layoutForView.layout = array[0]
             layoutForView.sort = array[1]
             layoutForView.ascending = NSString(string: array[2]).boolValue
@@ -102,11 +104,12 @@ class NCUtility: NSObject {
             layoutForView.directoryOnTop = NSString(string: array[4]).boolValue
             layoutForView.titleButtonHeader = array[5]
             layoutForView.itemForLine = Int(NSString(string: array[6]).intValue)
-                       
+            // version 2
             if array.count > 8 {
                 layoutForView.imageBackgroud = array[7]
                 layoutForView.imageBackgroudContentMode = array[8]
                 layoutForView.colorBackground = array[9]
+                layoutForView.colorDarkBackground = array[10]
             }
         }