marinofaggiana 4 年 前
コミット
c2e513a2fd

+ 34 - 15
iOSClient/BackgroundImageColor/NCBackgroundImageColor.storyboard

@@ -70,35 +70,52 @@
                                 <rect key="frame" x="0.0" y="308" width="300" height="125"/>
                                 <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="246" y="5" width="51" height="31"/>
+                                        <rect key="frame" x="241" y="3.5" width="51" height="31"/>
                                         <connections>
                                             <action selector="darkmodeAction:" destination="V0q-CP-xMJ" eventType="valueChanged" id="jpD-6b-nRS"/>
                                         </connections>
                                     </switch>
-                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Dark mode" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AH4-ei-W3C">
-                                        <rect key="frame" x="5" y="10" width="231" height="21"/>
-                                        <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="dark mode" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AH4-ei-W3C">
+                                        <rect key="frame" x="10" y="10" width="221" height="18"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                         <nil key="textColor"/>
                                         <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="5" y="51" width="290" height="34"/>
-                                        <color key="backgroundColor" systemColor="systemGray2Color"/>
-                                        <state key="normal" title="Button"/>
+                                        <rect key="frame" x="10" y="95" width="280" height="30"/>
+                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                                        <state key="normal" title="default color">
+                                            <color key="titleColor" systemColor="labelColor"/>
+                                        </state>
                                         <connections>
                                             <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="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="5" id="Afp-ca-hx0"/>
-                                    <constraint firstItem="6Dy-77-TIC" firstAttribute="leading" secondItem="Dsj-Of-TI5" secondAttribute="leading" constant="5" id="Bn8-Bi-qOg"/>
-                                    <constraint firstAttribute="trailing" secondItem="qCH-0e-MgJ" secondAttribute="trailing" constant="5" id="QVc-0U-Mg8"/>
-                                    <constraint firstItem="6Dy-77-TIC" firstAttribute="top" secondItem="AH4-ei-W3C" secondAttribute="bottom" constant="20" id="YpO-lB-kfU"/>
-                                    <constraint firstAttribute="trailing" secondItem="6Dy-77-TIC" secondAttribute="trailing" constant="5" id="jId-wH-r5I"/>
+                                    <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 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="bottom" secondItem="6Dy-77-TIC" secondAttribute="bottom" id="syt-rd-mmR"/>
                                     <constraint firstAttribute="height" constant="125" id="uSG-oG-ooi"/>
                                 </constraints>
                             </view>
@@ -140,6 +157,8 @@
                         <outlet property="defaultButton" destination="6Dy-77-TIC" id="PxM-tG-Ve7"/>
                         <outlet property="okButton" destination="hcV-V0-eZB" id="1VQ-qp-4Fs"/>
                         <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"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="qdm-Cl-C5l" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
@@ -148,12 +167,12 @@
         </scene>
     </scenes>
     <resources>
+        <systemColor name="labelColor">
+            <color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+        </systemColor>
         <systemColor name="systemBlueColor">
             <color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
         </systemColor>
-        <systemColor name="systemGray2Color">
-            <color red="0.68235294117647061" green="0.68235294117647061" blue="0.69803921568627447" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-        </systemColor>
         <systemColor name="systemGray4Color">
             <color red="0.81960784313725488" green="0.81960784313725488" blue="0.83921568627450982" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
         </systemColor>

+ 78 - 23
iOSClient/BackgroundImageColor/NCBackgroundImageColor.swift

@@ -31,6 +31,9 @@ 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!
@@ -39,16 +42,13 @@ class NCBackgroundImageColor: UIViewController {
     private let colorPicker = ChromaColorPicker()
     private let brightnessSlider = ChromaBrightnessSlider()
     private var colorHandle: ChromaColorHandle?
-    
     private let defaultColorPickerSize = CGSize(width: 200, height: 200)
     private let brightnessSliderWidthHeightRatio: CGFloat = 0.1
     
-    private var darkColorHexString = "#000000"
-    private var lightColorHexString = "#FFFFFF"
+    private var darkColor = ""      // "#000000"
+    private var lightColor = ""     // #FFFFFF
     
     public var collectionViewCommon: NCCollectionViewCommon?
-    public var defaultDarkColor: UIColor = .black
-    public var defaultLightColor: UIColor = .white
 
     let width: CGFloat = 300
     let height: CGFloat = 500
@@ -64,8 +64,17 @@ class NCBackgroundImageColor: UIViewController {
         
         titleLabel.text = NSLocalizedString("_background_", comment: "")
         darkmodeLabel.text = NSLocalizedString("_dark_mode_", comment: "")
+        useForAllLabel.text = NSLocalizedString("_default_color_all_folders_", comment: "")
+
+        defaultButton.setTitle(NSLocalizedString("_default_color_", comment: ""), for: .normal)
+
         cancelButton.setTitle(NSLocalizedString("_cancel_", comment: ""), for: .normal)
-        okButton.setTitle(NSLocalizedString("_ok_", comment: ""), for: .normal)        
+        okButton.setTitle(NSLocalizedString("_ok_", comment: ""), for: .normal)
+        
+        defaultButton.layer.cornerRadius = 10
+        defaultButton.layer.borderWidth = 0.5
+        defaultButton.layer.borderColor = UIColor.gray.cgColor
+        defaultButton.layer.masksToBounds = true
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -76,6 +85,37 @@ class NCBackgroundImageColor: UIViewController {
         } else {
             darkmodeSwitch.isOn = false
         }
+        
+        // Color for this view
+        if let collectionViewCommon = collectionViewCommon {
+            let layoutForView = NCUtility.shared.getLayoutForView(key: collectionViewCommon.layoutKey, serverUrl: collectionViewCommon.serverUrl)
+            darkColor = layoutForView.darkColorBackground
+            lightColor = layoutForView.lightColorBackground
+        }
+        
+        // Color all
+        if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
+            if darkColor == "" {
+                darkColor = activeAccount.darkColorFiles
+            }
+            if lightColor == "" {
+                lightColor = activeAccount.lightColorFiles
+            }
+        }
+        
+        if darkmodeSwitch.isOn {
+            if let color = UIColor.init(hex: darkColor) {
+                changeColor(color)
+            } else {
+                changeColor(.black)
+            }
+        } else {
+            if let color = UIColor.init(hex: lightColor) {
+                changeColor(color)
+            } else {
+                changeColor(.white)
+            }
+        }
     }
     
     override func viewDidAppear(_ animated: Bool) {
@@ -85,26 +125,36 @@ class NCBackgroundImageColor: UIViewController {
     // MARK: - Action
     
     @IBAction func darkmodeAction(_ sender: UISwitch) {
-        
-        var colorHexString = ""
-        
+                
         if sender.isOn {
-            colorHexString = darkColorHexString
-        } else {
-            colorHexString = lightColorHexString
-        }
-        
-        if let color = UIColor.init(hex: colorHexString) {
-            changeColor(color)
+            if darkColor == "" {
+                changeColor(.black)
+            } else {
+                if let color = UIColor.init(hex: darkColor) {
+                    changeColor(color)
+                }
+            }
         } else {
+            if lightColor == "" {
+                changeColor(.white)
+            } else {
+                if let color = UIColor.init(hex: lightColor) {
+                    changeColor(color)
+                }
+            }
         }
     }
     
     @IBAction func defaultAction(_ sender: Any) {
         
-        //changeColor(defaultColor)
-        darkColorHexString = ""
-        lightColorHexString = ""
+        darkColor = ""
+        lightColor = ""
+        
+        if darkmodeSwitch.isOn {
+            changeColor(.black)
+        } else {
+            changeColor(.white)
+        }
     }
     
     @IBAction func cancelAction(_ sender: Any) {
@@ -114,9 +164,14 @@ class NCBackgroundImageColor: UIViewController {
     
     @IBAction func okAction(_ sender: Any) {
         
-        if let collectionViewCommon = collectionViewCommon {
-            //NCUtility.shared.setBackgroundColorForView(key: collectionViewCommon.layoutKey, serverUrl: collectionViewCommon.serverUrl, colorBackground: "", colorDarkBackground: darkColorHexString)
+        if useForAllSwitch.isOn {
+            NCManageDatabase.shared.setAccountColorFiles(lightColorFiles: lightColor, darkColorFiles: darkColor)
+        } else {
+            if let collectionViewCommon = collectionViewCommon {
+                NCUtility.shared.setBackgroundColorForView(key: collectionViewCommon.layoutKey, serverUrl: collectionViewCommon.serverUrl, lightColorBackground: lightColor, darkColorBackground: darkColor)
+            }
         }
+        
         collectionViewCommon?.setLayout()
         dismiss(animated: true)
     }
@@ -172,9 +227,9 @@ extension NCBackgroundImageColor: ChromaColorPickerDelegate {
     func colorPickerHandleDidChange(_ colorPicker: ChromaColorPicker, handle: ChromaColorHandle, to color: UIColor) {
         
         if darkmodeSwitch.isOn {
-            darkColorHexString = color.hexString
+            darkColor = color.hexString
         } else {
-            lightColorHexString = color.hexString
+            lightColor = color.hexString
         }
         
         collectionViewCommon?.collectionView.backgroundColor = color

+ 2 - 2
iOSClient/Diagnostics/NCCapabilitiesViewController.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="vTK-Er-kbZ">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="vTK-Er-kbZ">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>

+ 2 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -176,6 +176,8 @@
 "_use_as_background_"       = "Use it as a background";
 "_background_"              = "Background";
 "_dark_mode_"               = "Dark mode";
+"_default_color_"           = "Use the default color";
+"_default_color_all_folders_" = "Use for all folders";
 
 /* User status */
 "_online_"                  = "Online";