Browse Source

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 năm trước cách đây
mục cha
commit
2054fac349

+ 4 - 4
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -803,7 +803,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         sortMenu.toggleMenu(viewController: self, key: layoutKey, sortButton: sender as? UIButton, serverUrl: serverUrl)
     }
 
-    func tapButtonUpload(_ sender: Any) {
+    func tapButton1(_ sender: Any) {
         NCAskAuthorization.shared.askAuthorizationPhotoLibrary(viewController: self) { hasPermission in
             if hasPermission {
                 NCPhotosPickerViewController.init(viewController: self, maxSelectedAssets: 0, singleSelectedMode: false)
@@ -811,13 +811,13 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         }
     }
 
-    func tapButtonCreateFolder(_ sender: Any) {
+    func tapButton2(_ sender: Any) {
         guard !appDelegate.activeServerUrl.isEmpty else { return }
         let alertController = UIAlertController.createFolder(serverUrl: appDelegate.activeServerUrl, urlBase: appDelegate)
         appDelegate.window?.rootViewController?.present(alertController, animated: true, completion: nil)
     }
 
-    func tapButtonScanDocument(_ sender: Any) {
+    func tapButton3(_ sender: Any) {
         if #available(iOS 13.0, *) {
             if let viewController = appDelegate.window?.rootViewController {
                 NCCreateScanDocument.shared.openScannerDocument(viewController: viewController)
@@ -1824,7 +1824,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 header.labelSection.textColor = NCBrandColor.shared.brandElement
 
                 header.setButtonsOneHeight(heightButtonsOne)
-                header.setButtonsTwoHeight(heightButtonsTwo)
+                header.setButtonsTwoHeight(heightButtonsTwo, imageButton1: UIImage(named: "buttonAddImage"), imageButton2: UIImage(named: "buttonAddFolder"), imageButton3: UIImage(named: "buttonAddScan"))
                 header.setRichWorkspaceHeight(heightHeaderRichWorkspace)
                 header.setSectionHeight(heightHeaderSection)
 

+ 57 - 47
iOSClient/Main/Section Header Footer/NCSectionHeaderFooter.swift

@@ -30,9 +30,9 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
     @IBOutlet weak var buttonOrder: UIButton!
     @IBOutlet weak var buttonMore: UIButton!
 
-    @IBOutlet weak var buttonUpload: UIButton!
-    @IBOutlet weak var buttonCreateFolder: UIButton!
-    @IBOutlet weak var buttonScanDocument: UIButton!
+    @IBOutlet weak var button1: UIButton!
+    @IBOutlet weak var button2: UIButton!
+    @IBOutlet weak var button3: UIButton!
 
     @IBOutlet weak var viewButtonsOne: UIView!
     @IBOutlet weak var viewButtonsTwo: UIView!
@@ -68,37 +68,32 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         buttonOrder.setTitleColor(.systemBlue, for: .normal)
         buttonMore.setImage(UIImage(named: "more")!.image(color: NCBrandColor.shared.systemGray1, size: 25), for: .normal)
 
-        let imageUpload = UIImage(named: "buttonAddImage")!.image(color: NCBrandColor.shared.systemGray1, size: 25)
-        buttonUpload.backgroundColor = .clear
-        buttonUpload.setTitleColor(.systemBlue, for: .normal)
-        buttonUpload.setTitle(NSLocalizedString("_upload_", comment: "").firstUppercased, for: .normal)
-        buttonUpload.layer.borderColor = NCBrandColor.shared.systemGray1.cgColor
-        buttonUpload.layer.borderWidth = 0.3
-        buttonUpload.layer.cornerRadius = 3
-        buttonUpload.setImage(imageUpload, for: .normal)
-
-        let imageFolder = UIImage(named: "buttonAddFolder")!.image(color: NCBrandColor.shared.systemGray1, size: 25)
-        buttonCreateFolder.backgroundColor = .clear
-        buttonCreateFolder.setTitleColor(.systemBlue, for: .normal)
-        buttonCreateFolder.setTitle(NSLocalizedString("_folder_", comment: "").firstUppercased, for: .normal)
-        buttonCreateFolder.layer.borderColor = NCBrandColor.shared.systemGray1.cgColor
-        buttonCreateFolder.layer.borderWidth = 0.3
-        buttonCreateFolder.layer.cornerRadius = 3
-        buttonCreateFolder.setImage(imageFolder, for: .normal)
-
-        let imageScan = NCUtility.shared.loadImage(named: "buttonAddScan").image(color: NCBrandColor.shared.systemGray1, size: 25)
-        buttonScanDocument.backgroundColor = .clear
-        buttonScanDocument.setTitleColor(.systemBlue, for: .normal)
-        buttonScanDocument.setTitle(NSLocalizedString("_scan_", comment: "").firstUppercased, for: .normal)
-        buttonScanDocument.layer.borderColor = NCBrandColor.shared.systemGray1.cgColor
-        buttonScanDocument.layer.borderWidth = 0.3
-        buttonScanDocument.layer.cornerRadius = 3
-        buttonScanDocument.setImage(imageScan, for: .normal)
-        if #available(iOS 13.0, *) {
-            buttonScanDocument.isHidden = false
-        } else {
-            buttonScanDocument.isHidden = true
-        }
+        button1.setImage(nil, for: .normal)
+        button1.isHidden = true
+        button1.backgroundColor = .clear
+        button1.setTitleColor(.systemBlue, for: .normal)
+        button1.setTitle(NSLocalizedString("_upload_", comment: "").firstUppercased, for: .normal)
+        button1.layer.borderColor = NCBrandColor.shared.systemGray1.cgColor
+        button1.layer.borderWidth = 0.3
+        button1.layer.cornerRadius = 3
+
+        button2.setImage(nil, for: .normal)
+        button2.isHidden = true
+        button2.backgroundColor = .clear
+        button2.setTitleColor(.systemBlue, for: .normal)
+        button2.setTitle(NSLocalizedString("_folder_", comment: "").firstUppercased, for: .normal)
+        button2.layer.borderColor = NCBrandColor.shared.systemGray1.cgColor
+        button2.layer.borderWidth = 0.3
+        button2.layer.cornerRadius = 3
+
+        button3.setImage(nil, for: .normal)
+        button3.isHidden = true
+        button3.backgroundColor = .clear
+        button3.setTitleColor(.systemBlue, for: .normal)
+        button3.setTitle(NSLocalizedString("_scan_", comment: "").firstUppercased, for: .normal)
+        button3.layer.borderColor = NCBrandColor.shared.systemGray1.cgColor
+        button3.layer.borderWidth = 0.3
+        button3.layer.cornerRadius = 3
 
         // Gradient
         gradient.startPoint = CGPoint(x: 0, y: 0.50)
@@ -195,13 +190,28 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         }
     }
 
-    func setButtonsTwoHeight(_ size:CGFloat) {
+    func setButtonsTwoHeight(_ size:CGFloat, imageButton1: UIImage? = nil, imageButton2: UIImage? = nil, imageButton3: UIImage? = nil) {
         viewButtonsTwoHeightConstraint.constant = size
         if size == 0 {
             viewButtonsTwo.isHidden = true
         } else {
             viewButtonsTwo.isHidden = false
         }
+        if var image = imageButton1 {
+            image = image.image(color: NCBrandColor.shared.systemGray1, size: 25)
+            button1.setImage(image, for: .normal)
+            button1.isHidden = false
+        }
+        if var image = imageButton2 {
+            image = image.image(color: NCBrandColor.shared.systemGray1, size: 25)
+            button2.setImage(image, for: .normal)
+            button2.isHidden = false
+        }
+        if var image = imageButton3 {
+            image = image.image(color: NCBrandColor.shared.systemGray1, size: 25)
+            button3.setImage(image, for: .normal)
+            button3.isHidden = false
+        }
     }
 
     func setRichWorkspaceHeight(_ size: CGFloat) {
@@ -234,16 +244,16 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         delegate?.tapButtonMore(sender)
     }
 
-    @IBAction func touchUpInsideButtonUpload(_ sender: Any) {
-       delegate?.tapButtonUpload(sender)
+    @IBAction func touchUpInsideButton1(_ sender: Any) {
+       delegate?.tapButton1(sender)
     }
 
-    @IBAction func touchUpInsideButtonCreateFolder(_ sender: Any) {
-        delegate?.tapButtonCreateFolder(sender)
+    @IBAction func touchUpInsideButton2(_ sender: Any) {
+        delegate?.tapButton2(sender)
     }
 
-    @IBAction func touchUpInsideButtonScanDocument(_ sender: Any) {
-        delegate?.tapButtonScanDocument(sender)
+    @IBAction func touchUpInsideButton3(_ sender: Any) {
+        delegate?.tapButton3(sender)
     }
 
     @objc func touchUpInsideViewRichWorkspace(_ sender: Any) {
@@ -255,9 +265,9 @@ protocol NCSectionHeaderMenuDelegate: AnyObject {
     func tapButtonSwitch(_ sender: Any)
     func tapButtonOrder(_ sender: Any)
     func tapButtonMore(_ sender: Any)
-    func tapButtonUpload(_ sender: Any)
-    func tapButtonCreateFolder(_ sender: Any)
-    func tapButtonScanDocument(_ sender: Any)
+    func tapButton1(_ sender: Any)
+    func tapButton2(_ sender: Any)
+    func tapButton3(_ sender: Any)
     func tapRichWorkspace(_ sender: Any)
 }
 
@@ -266,9 +276,9 @@ extension NCSectionHeaderMenuDelegate {
     func tapButtonSwitch(_ sender: Any) {}
     func tapButtonOrder(_ sender: Any) {}
     func tapButtonMore(_ sender: Any) {}
-    func tapButtonUpload(_ sender: Any) {}
-    func tapButtonCreateFolder(_ sender: Any) {}
-    func tapButtonScanDocument(_ sender: Any) {}
+    func tapButton1(_ sender: Any) {}
+    func tapButton2(_ sender: Any) {}
+    func tapButton3(_ sender: Any) {}
     func tapRichWorkspace(_ sender: Any) {}
 }
 

+ 6 - 6
iOSClient/Main/Section Header Footer/NCSectionHeaderMenu.xib

@@ -28,7 +28,7 @@
                             <inset key="imageEdgeInsets" minX="-8" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
                             <state key="normal" title="Button 1" image="buttonCreateFolder"/>
                             <connections>
-                                <action selector="touchUpInsideButtonUpload:" destination="tys-A2-nDX" eventType="touchUpInside" id="PRS-wE-LRC"/>
+                                <action selector="touchUpInsideButton1:" destination="tys-A2-nDX" eventType="touchUpInside" id="n7r-8n-gT3"/>
                             </connections>
                         </button>
                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cjh-je-E6h">
@@ -41,7 +41,7 @@
                             <inset key="imageEdgeInsets" minX="-8" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
                             <state key="normal" title="Button 2" image="buttonCreateFolder"/>
                             <connections>
-                                <action selector="touchUpInsideButtonCreateFolder:" destination="tys-A2-nDX" eventType="touchUpInside" id="v9i-Kt-hbI"/>
+                                <action selector="touchUpInsideButton2:" destination="tys-A2-nDX" eventType="touchUpInside" id="hek-Xq-Lh2"/>
                             </connections>
                         </button>
                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Zta-tv-COt">
@@ -54,7 +54,7 @@
                             <inset key="imageEdgeInsets" minX="-8" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
                             <state key="normal" title="Button 3" image="buttonCreateFolder"/>
                             <connections>
-                                <action selector="touchUpInsideButtonScanDocument:" destination="tys-A2-nDX" eventType="touchUpInside" id="chM-32-kSs"/>
+                                <action selector="touchUpInsideButton3:" destination="tys-A2-nDX" eventType="touchUpInside" id="Krk-cP-Iq5"/>
                             </connections>
                         </button>
                     </subviews>
@@ -178,12 +178,12 @@
                 <constraint firstItem="NC1-5C-E5z" firstAttribute="bottom" secondItem="f9U-NY-4OS" secondAttribute="top" id="pmY-5s-Pv2"/>
             </constraints>
             <connections>
-                <outlet property="buttonCreateFolder" destination="cjh-je-E6h" id="RUW-w2-cfw"/>
+                <outlet property="button1" destination="Hie-dN-B9L" id="kzL-vK-FCu"/>
+                <outlet property="button2" destination="cjh-je-E6h" id="jUf-rf-F2d"/>
+                <outlet property="button3" destination="Zta-tv-COt" id="jk9-MY-ylh"/>
                 <outlet property="buttonMore" destination="D0O-wK-14O" id="eEx-3R-zCS"/>
                 <outlet property="buttonOrder" destination="0bo-yl-t5k" id="Kbw-BG-73C"/>
-                <outlet property="buttonScanDocument" destination="Zta-tv-COt" id="D7n-8P-5l4"/>
                 <outlet property="buttonSwitch" destination="1LD-cd-zhc" id="Ec2-cM-CoY"/>
-                <outlet property="buttonUpload" destination="Hie-dN-B9L" id="AfM-W6-RDX"/>
                 <outlet property="labelSection" destination="mB5-5n-AL9" id="uxf-bN-nZA"/>
                 <outlet property="textViewRichWorkspace" destination="pYo-pF-MGv" id="2h4-LP-T1z"/>
                 <outlet property="viewButtonsOne" destination="4m9-yf-RbB" id="ym1-m0-plm"/>