Эх сурвалжийг харах

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 жил өмнө
parent
commit
13e2611113

+ 24 - 0
iOSClient/Color/NCColorPicker.storyboard

@@ -24,6 +24,9 @@
                                     <constraint firstAttribute="height" constant="40" id="U5p-9E-WGx"/>
                                 </constraints>
                                 <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                <connections>
+                                    <action selector="orangeButtonAction:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="qjx-Me-0xU"/>
+                                </connections>
                             </button>
                             <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Jc0-7X-JuE">
                                 <rect key="frame" x="60" y="21" width="250" height="18.5"/>
@@ -37,6 +40,9 @@
                                     <constraint firstAttribute="width" constant="40" id="pBq-i1-K9T"/>
                                 </constraints>
                                 <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                <connections>
+                                    <action selector="redButtonAction:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="b2r-oG-GvU"/>
+                                </connections>
                             </button>
                             <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="p7z-g7-hkV">
                                 <rect key="frame" x="60" y="71" width="250" height="18.5"/>
@@ -50,6 +56,9 @@
                                     <constraint firstAttribute="width" constant="40" id="v3I-Na-zQ5"/>
                                 </constraints>
                                 <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                <connections>
+                                    <action selector="violaButtonAction:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="hIN-qB-6r5"/>
+                                </connections>
                             </button>
                             <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="DoG-RI-jcO">
                                 <rect key="frame" x="60" y="121" width="250" height="18.5"/>
@@ -63,6 +72,9 @@
                                     <constraint firstAttribute="width" constant="40" id="n8f-nK-weh"/>
                                 </constraints>
                                 <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                <connections>
+                                    <action selector="blueButtonAction:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="M04-54-NPB"/>
+                                </connections>
                             </button>
                             <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Dmu-fr-Dtf">
                                 <rect key="frame" x="60" y="171" width="250" height="18.5"/>
@@ -76,6 +88,9 @@
                                     <constraint firstAttribute="width" constant="40" id="dHD-fs-7m0"/>
                                 </constraints>
                                 <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                <connections>
+                                    <action selector="yellowButtonAction:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="suP-DD-70c"/>
+                                </connections>
                             </button>
                             <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="gSF-6R-gbh">
                                 <rect key="frame" x="60" y="221" width="250" height="18.5"/>
@@ -89,6 +104,9 @@
                                     <constraint firstAttribute="width" constant="40" id="h5m-EQ-2Go"/>
                                 </constraints>
                                 <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                <connections>
+                                    <action selector="greenButtonAction:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="VVw-Ra-U8N"/>
+                                </connections>
                             </button>
                             <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="5XA-n8-8l6">
                                 <rect key="frame" x="60" y="271" width="250" height="18.5"/>
@@ -102,6 +120,9 @@
                                     <constraint firstAttribute="width" constant="40" id="y5l-31-c4D"/>
                                 </constraints>
                                 <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                <connections>
+                                    <action selector="grayButtonAction:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="wP2-wX-3Hl"/>
+                                </connections>
                             </button>
                             <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="DFY-QC-J1R">
                                 <rect key="frame" x="60" y="321" width="250" height="18.5"/>
@@ -115,6 +136,9 @@
                                     <constraint firstAttribute="width" constant="40" id="L0n-3P-wA1"/>
                                 </constraints>
                                 <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                <connections>
+                                    <action selector="defaultButtonAction:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="VhY-1n-fwQ"/>
+                                </connections>
                             </button>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AVl-ZW-qt0">
                                 <rect key="frame" x="60" y="380" width="250" height="0.0"/>

+ 43 - 17
iOSClient/Color/NCColorPicker.swift

@@ -9,20 +9,7 @@
 import Foundation
 import UIKit
 
-public protocol NCColorPickerDelegate: AnyObject {
-    func colorPickerCancel()
-    func colorPickerWillChange(color: UIColor)
-    func colorPickerDidChange(color: UIColor)
-}
-
-// optional func
-public extension NCColorPickerDelegate {
-    func colorPickerCancel() {}
-    func colorPickerWillChange(color: UIColor) { }
-    func colorPickerDidChange(color: UIColor) { }
-}
-
-class NCColorPicker: UIViewController, NCColorPickerDelegate {
+class NCColorPicker: UIViewController {
 
     @IBOutlet weak var orangeButton: UIButton!
     @IBOutlet weak var redButton: UIButton!
@@ -42,9 +29,7 @@ class NCColorPicker: UIViewController, NCColorPickerDelegate {
     @IBOutlet weak var grayText: UITextField!
     @IBOutlet weak var defaultLabel: UILabel!
 
-    weak var delegate: NCColorPickerDelegate?
-    var selectedColor: UIColor?
-    var defaultColor: UIColor?
+    var metadata: tableMetadata?
 
     // MARK: - View Life Cycle
 
@@ -91,4 +76,45 @@ class NCColorPicker: UIViewController, NCColorPickerDelegate {
         defaultButton.layer.masksToBounds = true
         defaultLabel.text = NSLocalizedString("_default_", comment: "")
     }
+
+    @IBAction func orangeButtonAction(_ sender: UIButton) {
+        UpdateColor(hexColor: UIColor.orange.hexString)
+    }
+
+    @IBAction func redButtonAction(_ sender: UIButton) {
+        UpdateColor(hexColor: UIColor.red.hexString)
+    }
+
+    @IBAction func violaButtonAction(_ sender: UIButton) {
+        UpdateColor(hexColor: "#8f00ff")
+    }
+
+    @IBAction func blueButtonAction(_ sender: UIButton) {
+        UpdateColor(hexColor: UIColor.blue.hexString)
+    }
+
+    @IBAction func yellowButtonAction(_ sender: UIButton) {
+        UpdateColor(hexColor: UIColor.yellow.hexString)
+    }
+
+    @IBAction func greenButtonAction(_ sender: UIButton) {
+        UpdateColor(hexColor: UIColor.green.hexString)
+    }
+
+    @IBAction func grayButtonAction(_ sender: UIButton) {
+        UpdateColor(hexColor: UIColor.gray.hexString)
+    }
+
+    @IBAction func defaultButtonAction(_ sender: UIButton) {
+        UpdateColor(hexColor: NCBrandColor.shared.brandElement.hexString)
+    }
+
+    func UpdateColor(hexColor: String?) {
+        if let metadata = metadata {
+            let serverUrl = metadata.serverUrl + "/" + metadata.fileName
+            if NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, colorFolder: hexColor, account: metadata.account) != nil {
+                //reloadDataSource()
+            }
+        }
+    }
 }

+ 0 - 17
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -41,7 +41,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     internal var isEditMode = false
     internal var selectOcId: [String] = []
     internal var metadataFolder: tableMetadata?
-    internal var menuMetadata: tableMetadata?
     internal var dataSource = NCDataSource()
     internal var richWorkspaceText: String?
     internal var headerMenu: NCSectionHeaderMenu?
@@ -1920,19 +1919,3 @@ extension NCCollectionViewCommon: EasyTipViewDelegate {
     }
 }
 
-extension NCCollectionViewCommon: NCColorPickerDelegate {
-
-    /*
-    func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) {
-
-        if let metadata = menuMetadata {
-            let serverUrl = metadata.serverUrl + "/" + metadata.fileName
-            let hexColor = viewController.selectedColor.hexString
-            if NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, colorFolder: hexColor, account: metadata.account) != nil {
-                reloadDataSource()
-            }
-        }
-    }
-    */
-}
-

+ 2 - 10
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -37,7 +37,6 @@ extension NCCollectionViewCommon {
         var actions = [NCMenuAction]()
 
         guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(metadata.ocId) else { return }
-        self.menuMetadata = metadata
         let serverUrl = metadata.serverUrl + "/" + metadata.fileName
         let isFolderEncrypted = CCUtility.isFolderEncrypted(metadata.serverUrl, e2eEncrypted: metadata.e2eEncrypted, account: metadata.account, urlBase: metadata.urlBase)
         let serverUrlHome = NCUtilityFileSystem.shared.getHomeServer(account: appDelegate.account)
@@ -309,16 +308,9 @@ extension NCCollectionViewCommon {
                     icon: NCUtility.shared.loadImage(named: "palette"),
                     action: { _ in
                         if let picker = UIStoryboard(name: "NCColorPicker", bundle: nil).instantiateInitialViewController() as? NCColorPicker {
-
-                            picker.delegate = self
-                            if let colorFolderHex = tableDirectory?.colorFolder {
-                                picker.selectedColor = UIColor.init(hex: colorFolderHex)
-                            }
-                            picker.defaultColor = NCBrandColor.shared.brandElement
-
-                            let popup = NCPopupViewController(contentController: picker, popupWidth: 300, popupHeight: 450)
+                            picker.metadata = metadata
+                            let popup = NCPopupViewController(contentController: picker, popupWidth: 200, popupHeight: 410)
                             popup.backgroundAlpha = 0
-
                             self.present(popup, animated: true)
                         }
                     }