marinofaggiana 3 жил өмнө
parent
commit
d61b40df4a

+ 10 - 26
iOSClient/BackgroundImageColor/NCBackgroundImageColor.storyboard

@@ -14,7 +14,7 @@
             <objects>
                 <viewController id="V0q-CP-xMJ" customClass="NCBackgroundImageColor" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="gzh-6E-hc4">
-                        <rect key="frame" x="0.0" y="0.0" width="300" height="485"/>
+                        <rect key="frame" x="0.0" y="0.0" width="300" height="450"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Background" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nZr-nE-ths">
@@ -103,21 +103,21 @@
                                 </constraints>
                             </view>
                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7CJ-Q0-ABH" userLabel="SeparatorV">
-                                <rect key="frame" x="150" y="435" width="0.5" height="50"/>
+                                <rect key="frame" x="150" y="400" width="0.5" height="50"/>
                                 <color key="backgroundColor" systemColor="systemGray4Color"/>
                                 <constraints>
                                     <constraint firstAttribute="width" constant="0.5" id="wU1-tA-NZk"/>
                                 </constraints>
                             </view>
                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ouH-gK-Guv" userLabel="SeparatorH">
-                                <rect key="frame" x="0.0" y="434.5" width="300" height="0.5"/>
+                                <rect key="frame" x="0.0" y="399.5" width="300" height="0.5"/>
                                 <color key="backgroundColor" systemColor="systemGray4Color"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="0.5" id="2OQ-Mt-Gnh"/>
                                 </constraints>
                             </view>
                             <button opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="249" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="W5y-aT-UlI">
-                                <rect key="frame" x="0.0" y="435" width="150" height="50"/>
+                                <rect key="frame" x="0.0" y="400" width="150" height="50"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="50" id="xnX-6W-gp9"/>
                                 </constraints>
@@ -130,7 +130,7 @@
                                 </connections>
                             </button>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hcV-V0-eZB">
-                                <rect key="frame" x="150" y="435" width="150" height="50"/>
+                                <rect key="frame" x="150" y="400" width="150" height="50"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                 <state key="normal" title="Ok">
                                     <color key="titleColor" systemColor="systemBlueColor"/>
@@ -140,7 +140,7 @@
                                 </connections>
                             </button>
                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Dsj-Of-TI5">
-                                <rect key="frame" x="0.0" y="308" width="300" height="120"/>
+                                <rect key="frame" x="0.0" y="308" width="300" height="80"/>
                                 <subviews>
                                     <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qCH-0e-MgJ">
                                         <rect key="frame" x="241" y="3.5" width="51" height="31"/>
@@ -155,7 +155,7 @@
                                         <nil key="highlightedColor"/>
                                     </label>
                                     <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6Dy-77-TIC">
-                                        <rect key="frame" x="10" y="85.5" width="280" height="30"/>
+                                        <rect key="frame" x="10" y="43" width="280" height="30"/>
                                         <color key="backgroundColor" systemColor="systemGray4Color"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="30" id="ZKT-Su-3nU"/>
@@ -168,31 +168,17 @@
                                             <action selector="defaultAction:" destination="V0q-CP-xMJ" eventType="touchUpInside" id="iTy-8K-wVB"/>
                                         </connections>
                                     </button>
-                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="use for all folders" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="byB-wK-0AW">
-                                        <rect key="frame" x="10" y="51" width="221" height="18"/>
-                                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
-                                        <nil key="textColor"/>
-                                        <nil key="highlightedColor"/>
-                                    </label>
-                                    <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ber-cK-0ag">
-                                        <rect key="frame" x="241" y="44.5" width="51" height="31"/>
-                                    </switch>
                                 </subviews>
                                 <constraints>
-                                    <constraint firstItem="ber-cK-0ag" firstAttribute="leading" secondItem="byB-wK-0AW" secondAttribute="trailing" constant="10" id="1IK-Qb-eQ9"/>
-                                    <constraint firstItem="ber-cK-0ag" firstAttribute="top" secondItem="qCH-0e-MgJ" secondAttribute="bottom" constant="10" id="1hL-LG-oe7"/>
+                                    <constraint firstItem="6Dy-77-TIC" firstAttribute="top" secondItem="AH4-ei-W3C" secondAttribute="bottom" constant="15" id="0J5-Y3-Z2f"/>
                                     <constraint firstItem="qCH-0e-MgJ" firstAttribute="centerY" secondItem="AH4-ei-W3C" secondAttribute="centerY" id="7pt-EI-Zgu"/>
                                     <constraint firstItem="AH4-ei-W3C" firstAttribute="top" secondItem="Dsj-Of-TI5" secondAttribute="top" constant="10" id="9E5-Em-VG8"/>
                                     <constraint firstItem="qCH-0e-MgJ" firstAttribute="leading" secondItem="AH4-ei-W3C" secondAttribute="trailing" constant="10" id="9qm-mi-Gwb"/>
                                     <constraint firstItem="AH4-ei-W3C" firstAttribute="leading" secondItem="Dsj-Of-TI5" secondAttribute="leading" constant="10" id="Afp-ca-hx0"/>
-                                    <constraint firstItem="byB-wK-0AW" firstAttribute="leading" secondItem="Dsj-Of-TI5" secondAttribute="leading" constant="10" id="BC4-qA-KON"/>
                                     <constraint firstItem="6Dy-77-TIC" firstAttribute="leading" secondItem="Dsj-Of-TI5" secondAttribute="leading" constant="10" id="Bn8-Bi-qOg"/>
-                                    <constraint firstItem="6Dy-77-TIC" firstAttribute="top" secondItem="ber-cK-0ag" secondAttribute="bottom" constant="10" id="Oep-Uf-mfT"/>
                                     <constraint firstAttribute="trailing" secondItem="qCH-0e-MgJ" secondAttribute="trailing" constant="10" id="QVc-0U-Mg8"/>
-                                    <constraint firstItem="byB-wK-0AW" firstAttribute="centerY" secondItem="ber-cK-0ag" secondAttribute="centerY" id="ZgE-VD-ukf"/>
-                                    <constraint firstAttribute="trailing" secondItem="ber-cK-0ag" secondAttribute="trailing" constant="10" id="gqK-e6-M7X"/>
                                     <constraint firstAttribute="trailing" secondItem="6Dy-77-TIC" secondAttribute="trailing" constant="10" id="jId-wH-r5I"/>
-                                    <constraint firstAttribute="height" constant="120" id="uSG-oG-ooi"/>
+                                    <constraint firstAttribute="height" constant="80" id="uSG-oG-ooi"/>
                                 </constraints>
                             </view>
                         </subviews>
@@ -224,7 +210,7 @@
                         </constraints>
                     </view>
                     <navigationItem key="navigationItem" id="Zon-2j-rsc"/>
-                    <size key="freeformSize" width="300" height="485"/>
+                    <size key="freeformSize" width="300" height="450"/>
                     <connections>
                         <outlet property="blackButton" destination="STo-4B-X2d" id="XwW-Q1-u9Y"/>
                         <outlet property="cancelButton" destination="W5y-aT-UlI" id="P9l-o1-miU"/>
@@ -237,8 +223,6 @@
                         <outlet property="orangeButton" destination="wje-qo-0av" id="LN8-3w-Wtx"/>
                         <outlet property="redButton" destination="aan-mm-3h8" id="X89-dx-fGV"/>
                         <outlet property="titleLabel" destination="nZr-nE-ths" id="UbA-Dl-0Ad"/>
-                        <outlet property="useForAllLabel" destination="byB-wK-0AW" id="HKs-m2-SBz"/>
-                        <outlet property="useForAllSwitch" destination="ber-cK-0ag" id="D2m-GW-l2t"/>
                         <outlet property="whiteButton" destination="3E4-fA-LuC" id="mNg-2f-rvs"/>
                     </connections>
                 </viewController>

+ 14 - 49
iOSClient/BackgroundImageColor/NCBackgroundImageColor.swift

@@ -27,14 +27,14 @@ import ChromaColorPicker
 public protocol NCBackgroundImageColorDelegate {
     func colorPickerCancel()
     func colorPickerWillChange(color: UIColor)
-    func colorPickerDidChange(lightColor: String, darkColor: String, useForAll: Bool)
+    func colorPickerDidChange(lightColor: String, darkColor: String)
 }
 
 // optional func
 public extension NCBackgroundImageColorDelegate {
     func colorPickerCancel() {}
     func colorPickerWillChange(color: UIColor) { }
-    func colorPickerDidChange(lightColor: String, darkColor: String, useForAll: Bool) { }
+    func colorPickerDidChange(lightColor: String, darkColor: String) { }
 }
 
 class NCBackgroundImageColor: UIViewController {
@@ -51,9 +51,6 @@ class NCBackgroundImageColor: UIViewController {
     @IBOutlet weak var darkmodeLabel: UILabel!
     @IBOutlet weak var darkmodeSwitch: UISwitch!
     
-    @IBOutlet weak var useForAllLabel: UILabel!
-    @IBOutlet weak var useForAllSwitch: UISwitch!
-
     @IBOutlet weak var defaultButton: UIButton!
     @IBOutlet weak var cancelButton: UIButton!
     @IBOutlet weak var okButton: UIButton!
@@ -64,15 +61,13 @@ class NCBackgroundImageColor: UIViewController {
     private let defaultColorPickerSize = CGSize(width: 200, height: 200)
     private let brightnessSliderWidthHeightRatio: CGFloat = 0.1
     
-    private var darkColor = ""
-    private var lightColor = ""
-    
     var delegate: NCBackgroundImageColorDelegate?
     var setupColor: UIColor?
-    var layoutForView: NCGlobal.layoutForViewType?
-
+    var darkColor = "#000000"
+    var lightColor = "#FFFFFF"
+    
     let width: CGFloat = 300
-    let height: CGFloat = 485
+    let height: CGFloat = 450
     
     // MARK: - View Life Cycle
 
@@ -85,7 +80,6 @@ class NCBackgroundImageColor: UIViewController {
         
         titleLabel.text = NSLocalizedString("_background_", comment: "")
         darkmodeLabel.text = NSLocalizedString("_dark_mode_", comment: "")
-        useForAllLabel.text = NSLocalizedString("_as_default_color_", comment: "")
 
         defaultButton.setTitle(NSLocalizedString("_default_color_", comment: ""), for: .normal)
 
@@ -136,14 +130,7 @@ class NCBackgroundImageColor: UIViewController {
         } else {
             darkmodeSwitch.isOn = false
         }
-        useForAllSwitch.isOn = false
-        
-        // Color for this view
-        if let layoutForView = layoutForView {
-            darkColor = layoutForView.darkColorBackground
-            lightColor = layoutForView.lightColorBackground
-        }
-        
+
         // Color for all folders
         if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
             if darkColor == "" {
@@ -219,34 +206,12 @@ class NCBackgroundImageColor: UIViewController {
     
     @IBAction func defaultAction(_ sender: Any) {
         
-        if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
-            if darkmodeSwitch.isOn {
-                if useForAllSwitch.isOn {
-                    darkColor = ""
-                    changeColor(.black)
-                } else {
-                    if let color = UIColor.init(hex: activeAccount.darkColorBackground) {
-                        darkColor = activeAccount.darkColorBackground
-                        changeColor(color)
-                    } else {
-                        darkColor = ""
-                        changeColor(.black)
-                    }
-                }
-            } else {
-                if useForAllSwitch.isOn {
-                    lightColor = "#FFFFFF"
-                    changeColor(.white)
-                } else {
-                    if let color = UIColor.init(hex:  activeAccount.lightColorBackground) {
-                        lightColor = activeAccount.lightColorBackground
-                        changeColor(color)
-                    } else {
-                        lightColor = "#FFFFFF"
-                        changeColor(.white)
-                    }
-                }
-            }
+        if darkmodeSwitch.isOn {
+            darkColor = "#000000"
+            changeColor(.black)
+        } else {
+            lightColor = "#FFFFFF"
+            changeColor(.white)
         }
     }
     
@@ -264,7 +229,7 @@ class NCBackgroundImageColor: UIViewController {
         if lightColor == "#FFFFFF" { lightColor = "" }
         if darkColor == "#000000" { darkColor = "" }
         
-        self.delegate?.colorPickerDidChange(lightColor: lightColor, darkColor: darkColor, useForAll: useForAllSwitch.isOn)
+        self.delegate?.colorPickerDidChange(lightColor: lightColor, darkColor: darkColor)
         
         dismiss(animated: true)
     }

+ 10 - 16
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -628,17 +628,13 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         // COLOR BACKGROUND
         let activeAccount = NCManageDatabase.shared.getActiveAccount()
         if traitCollection.userInterfaceStyle == .dark {
-            if layoutForView?.darkColorBackground != "" {
-                collectionView.backgroundColor = UIColor.init(hex: layoutForView?.darkColorBackground ?? "")
-            } else if activeAccount?.darkColorBackground != "" {
+            if activeAccount?.darkColorBackground != "" {
                 collectionView.backgroundColor = UIColor.init(hex: activeAccount?.darkColorBackground ?? "")
             } else {
                 collectionView.backgroundColor = defaultBackgroundColor
             }
         } else {
-            if layoutForView?.lightColorBackground != "" {
-                collectionView.backgroundColor = UIColor.init(hex: layoutForView?.lightColorBackground ?? "")
-            } else if activeAccount?.lightColorBackground != "" {
+           if activeAccount?.lightColorBackground != "" {
                 collectionView.backgroundColor = UIColor.init(hex: activeAccount?.lightColorBackground ?? "")
             } else {
                 collectionView.backgroundColor = defaultBackgroundColor
@@ -658,15 +654,10 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         collectionView.backgroundColor = color
     }
     
-    func colorPickerDidChange(lightColor: String, darkColor: String, useForAll: Bool) {
-        
-        if useForAll {
-            NCManageDatabase.shared.setAccountColorFiles(lightColorBackground: lightColor, darkColorBackground: darkColor)
-            NCUtility.shared.setBackgroundColorForView(key: layoutKey, serverUrl: serverUrl, lightColorBackground: "", darkColorBackground: "")
-        } else {
-            NCUtility.shared.setBackgroundColorForView(key: layoutKey, serverUrl: serverUrl, lightColorBackground: lightColor, darkColorBackground: darkColor)
-        }
-        
+    func colorPickerDidChange(lightColor: String, darkColor: String) {
+
+        NCManageDatabase.shared.setAccountColorFiles(lightColorBackground: lightColor, darkColorBackground: darkColor)
+               
         setLayout()
     }
         
@@ -954,7 +945,10 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             
             vcBackgroundImageColor.delegate = self
             vcBackgroundImageColor.setupColor = collectionView.backgroundColor
-            vcBackgroundImageColor.layoutForView = layoutForView
+            if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
+                vcBackgroundImageColor.lightColor = activeAccount.lightColorBackground
+                vcBackgroundImageColor.darkColor = activeAccount.darkColorBackground
+            }
             
             let popup = NCPopupViewController(contentController: vcBackgroundImageColor, popupWidth: vcBackgroundImageColor.width, popupHeight: vcBackgroundImageColor.height)
             popup.backgroundAlpha = 0

+ 0 - 2
iOSClient/NCGlobal.swift

@@ -49,8 +49,6 @@ class NCGlobal: NSObject {
         var itemForLine: Int
         var imageBackgroud: String
         var imageBackgroudContentMode: String
-        var lightColorBackground: String
-        var darkColorBackground: String
     }
     
     // Directory on Group

+ 5 - 15
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.lightColorBackground + "|" + layoutForView.darkColorBackground
+        let string =  layoutForView.layout + "|" + layoutForView.sort + "|" + "\(layoutForView.ascending)" + "|" + layoutForView.groupBy + "|" + "\(layoutForView.directoryOnTop)" + "|" + layoutForView.titleButtonHeader + "|" + "\(layoutForView.itemForLine)" + "|" + layoutForView.imageBackgroud + "|" + layoutForView.imageBackgroudContentMode
         var keyStore = key
         
         if serverUrl != "" {
@@ -59,17 +59,7 @@ class NCUtility: NSObject {
             setLayoutForView(key: key, serverUrl: serverUrl, layoutForView: layoutForView)
         }
     }
-    
-    func setBackgroundColorForView(key: String, serverUrl: String, lightColorBackground: String, darkColorBackground: String) {
-        
-        var layoutForView: NCGlobal.layoutForViewType = NCUtility.shared.getLayoutForView(key: key, serverUrl: serverUrl)
-        
-        layoutForView.lightColorBackground = lightColorBackground
-        layoutForView.darkColorBackground = darkColorBackground
-        
-        setLayoutForView(key: key, serverUrl: serverUrl, layoutForView: layoutForView)
-    }
-    
+
     func setBackgroundImageForView(key: String, serverUrl: String, imageBackgroud: String, imageBackgroudContentMode: String) {
         
         var layoutForView: NCGlobal.layoutForViewType = NCUtility.shared.getLayoutForView(key: key, serverUrl: serverUrl)
@@ -83,7 +73,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: "", lightColorBackground: "", darkColorBackground: "")
+        var layoutForView: NCGlobal.layoutForViewType = NCGlobal.layoutForViewType(layout: NCGlobal.shared.layoutList, sort: sort, ascending: ascending, groupBy: "none", directoryOnTop: true, titleButtonHeader: titleButtonHeader, itemForLine: 3, imageBackgroud: "", imageBackgroudContentMode: "")
         
         if serverUrl != "" {
             keyStore = serverUrl
@@ -108,8 +98,8 @@ class NCUtility: NSObject {
             if array.count > 8 {
                 layoutForView.imageBackgroud = array[7]
                 layoutForView.imageBackgroudContentMode = array[8]
-                layoutForView.lightColorBackground = array[9]
-                layoutForView.darkColorBackground = array[10]
+                //layoutForView.lightColorBackground = array[9] WAS STRING
+                //layoutForView.darkColorBackground = array[10] WAS STRING
             }
         }