ソースを参照

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 年 前
コミット
85d7d8964e

+ 1 - 1
iOSClient/Favorites/NCFavorite.swift

@@ -33,7 +33,7 @@ class NCFavorite: NCCollectionViewCommon {
 
         titleCurrentFolder = NSLocalizedString("_favorites_", comment: "")
         layoutKey = NCGlobal.shared.layoutViewFavorite
-        enableSearchBar = true
+        enableSearchBar = false
         emptyImage = UIImage(named: "star.fill")?.image(color: NCBrandColor.shared.yellowFavorite, size: UIScreen.main.bounds.width)
         emptyTitle = "_favorite_no_files_"
         emptyDescription = "_tutorial_favorite_view_"

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

@@ -65,6 +65,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     internal var layoutKey = ""
     internal var titleCurrentFolder = ""
     internal var enableSearchBar: Bool = false
+    internal var headerMenuButtonsCommand: Bool = true
+    internal var headerMenuButtonsView: Bool = true
     internal var emptyImage: UIImage?
     internal var emptyTitle: String = ""
     internal var emptyDescription: String = ""
@@ -115,7 +117,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         }
 
         // Empty
-        emptyDataSet = NCEmptyDataSet(view: collectionView, offset: NCGlobal.shared.heightButtonsCommand + NCGlobal.shared.heightButtonsView, delegate: self)
+        emptyDataSet = NCEmptyDataSet(view: collectionView, offset: getHeaderHeight(), delegate: self)
 
         // Long Press on CollectionView
         let longPressedGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressCollecationView(_:)))
@@ -1820,16 +1822,25 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 }
 
                 header.delegate = self
-                header.setStatusButtonsView(enable: !dataSource.metadatasSource.isEmpty)
-                header.setSortedTitle(layoutForView?.titleButtonHeader ?? "")
-                header.setRichWorkspaceText(richWorkspaceText)
-                header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath).firstUppercased
-                header.labelSection.textColor = NCBrandColor.shared.brandElement
+                if headerMenuButtonsCommand {
+                    header.setButtonsCommand(heigt: NCGlobal.shared.heightButtonsCommand, imageButton1: UIImage(named: "buttonAddImage"), titleButton1: NSLocalizedString("_upload_", comment: ""), imageButton2: UIImage(named: "buttonAddFolder"), titleButton2: NSLocalizedString("_folder_", comment: ""), imageButton3: UIImage(named: "buttonAddScan"), titleButton3: NSLocalizedString("_scan_", comment: ""))
+                } else {
+                    header.setButtonsCommand(heigt: 0)
+                }
+                if headerMenuButtonsView {
+                    header.setStatusButtonsView(enable: !dataSource.metadatasSource.isEmpty)
+                    header.setButtonsView(heigt: NCGlobal.shared.heightButtonsView)
+                    header.setSortedTitle(layoutForView?.titleButtonHeader ?? "")
+                } else {
+                    header.setButtonsView(heigt: 0)
+                }
 
-                header.setButtonsView(heigt: NCGlobal.shared.heightButtonsView)
-                header.setButtonsCommand(heigt: NCGlobal.shared.heightButtonsCommand, imageButton1: UIImage(named: "buttonAddImage"), titleButton1: NSLocalizedString("_upload_", comment: ""), imageButton2: UIImage(named: "buttonAddFolder"), titleButton2: NSLocalizedString("_folder_", comment: ""), imageButton3: UIImage(named: "buttonAddScan"), titleButton3: NSLocalizedString("_scan_", comment: ""))
                 header.setRichWorkspaceHeight(heightHeaderRichWorkspace)
+                header.setRichWorkspaceText(richWorkspaceText)
+
                 header.setSectionHeight(heightHeaderSection)
+                header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath).firstUppercased
+                header.labelSection.textColor = NCBrandColor.shared.brandElement
 
                 return header
 
@@ -1861,6 +1872,20 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
 
 extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
 
+    func getHeaderHeight() -> CGFloat {
+
+        var size: CGFloat = 0
+
+        if headerMenuButtonsCommand {
+            size += NCGlobal.shared.heightButtonsCommand
+        }
+        if headerMenuButtonsView {
+            size += NCGlobal.shared.heightButtonsView
+        }
+
+        return size
+    }
+
     func getHeaderHeight(section:Int) -> (heightHeaderCommands: CGFloat, heightHeaderRichWorkspace: CGFloat, heightHeaderSection: CGFloat) {
 
         var headerRichWorkspace: CGFloat = 0
@@ -1873,9 +1898,9 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
         }
 
         if section == 0 && dataSource.numberOfSections() > 1 {
-            return (NCGlobal.shared.heightButtonsCommand + NCGlobal.shared.heightButtonsView, headerRichWorkspace, NCGlobal.shared.heightSection)
+            return (getHeaderHeight(), headerRichWorkspace, NCGlobal.shared.heightSection)
         } else if section == 0 && dataSource.numberOfSections() == 1 {
-            return (NCGlobal.shared.heightButtonsCommand + NCGlobal.shared.heightButtonsView, headerRichWorkspace, 0)
+            return (getHeaderHeight(), headerRichWorkspace, 0)
         } else if section > 0 && dataSource.numberOfSections() > 1 {
             return (0, 0, NCGlobal.shared.heightSection)
         } else {

+ 31 - 38
iOSClient/Main/Section Header Footer/NCSectionHeaderFooter.swift

@@ -49,7 +49,6 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
     @IBOutlet weak var textViewRichWorkspace: UITextView!
     @IBOutlet weak var labelSection: UILabel!
 
-
     weak var delegate: NCSectionHeaderMenuDelegate?
 
     private var markdownParser = MarkdownParser()
@@ -88,7 +87,6 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         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
@@ -116,7 +114,6 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         viewSectionHeightConstraint.constant = 0
     }
 
-//    33
     override func layoutSublayers(of layer: CALayer) {
         super.layoutSublayers(of: layer)
         gradient.frame = viewRichWorkspace.bounds
@@ -127,37 +124,7 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         setGradientColor()
     }
 
-    //MARK: -
-
-    func setGradientColor() {
-        if traitCollection.userInterfaceStyle == .dark {
-            gradient.colors = [UIColor(white: 0, alpha: 0).cgColor, UIColor.black.cgColor]
-            viewSeparator.backgroundColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.0)
-        } else {
-            gradient.colors = [UIColor(white: 1, alpha: 0).cgColor, UIColor.white.cgColor]
-            viewSeparator.backgroundColor = UIColor(red: 0.79, green: 0.79, blue: 0.79, alpha: 1.0)
-        }
-    }
-
-    func setSortedTitle(_ title: String) {
-
-        let title = NSLocalizedString(title, comment: "")
-        //let size = title.size(withAttributes: [.font: buttonOrder.titleLabel?.font as Any])
-
-        buttonOrder.setTitle(title, for: .normal)
-    }
-
-    func setRichWorkspaceText(_ text: String?) {
-        guard let text = text else { return }
-        if text != self.richWorkspaceText {
-            textViewRichWorkspace.attributedText = markdownParser.parse(text)
-            self.richWorkspaceText = text
-        }
-    }
-
-    //MARK: -
-
-    // Command
+    //MARK: - Command
 
     func setStatusButtonsCommand(enable: Bool) {
         button1.isEnabled = enable
@@ -192,7 +159,7 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         }
     }
 
-    // View
+    //MARK: - View
 
     func setStatusButtonsView(enable: Bool) {
         buttonSwitch.isEnabled = enable
@@ -221,7 +188,15 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         }
     }
 
-    // RichWorkspace
+    func setSortedTitle(_ title: String) {
+
+        let title = NSLocalizedString(title, comment: "")
+        //let size = title.size(withAttributes: [.font: buttonOrder.titleLabel?.font as Any])
+
+        buttonOrder.setTitle(title, for: .normal)
+    }
+
+    //MARK: - RichWorkspace
 
     func setRichWorkspaceHeight(_ size: CGFloat) {
         viewRichWorkspaceHeightConstraint.constant = size
@@ -232,7 +207,25 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         }
     }
 
-    // Section
+    func setGradientColor() {
+        if traitCollection.userInterfaceStyle == .dark {
+            gradient.colors = [UIColor(white: 0, alpha: 0).cgColor, UIColor.black.cgColor]
+            viewSeparator.backgroundColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.0)
+        } else {
+            gradient.colors = [UIColor(white: 1, alpha: 0).cgColor, UIColor.white.cgColor]
+            viewSeparator.backgroundColor = UIColor(red: 0.79, green: 0.79, blue: 0.79, alpha: 1.0)
+        }
+    }
+
+    func setRichWorkspaceText(_ text: String?) {
+        guard let text = text else { return }
+        if text != self.richWorkspaceText {
+            textViewRichWorkspace.attributedText = markdownParser.parse(text)
+            self.richWorkspaceText = text
+        }
+    }
+
+    //MARK: - Section
 
     func setSectionHeight(_ size:CGFloat) {
         viewSectionHeightConstraint.constant = size
@@ -243,7 +236,7 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         }
     }
 
-    // MARK: -
+    // MARK: - Action
 
     @IBAction func touchUpInsideSwitch(_ sender: Any) {
         delegate?.tapButtonSwitch(sender)

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

@@ -19,7 +19,7 @@
                     <rect key="frame" x="0.0" y="0.0" width="551" height="50"/>
                     <subviews>
                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Hie-dN-B9L">
-                            <rect key="frame" x="10" y="10" width="99" height="40"/>
+                            <rect key="frame" x="10" y="11" width="99" height="40"/>
                             <constraints>
                                 <constraint firstAttribute="height" constant="40" id="X1Q-Rt-PQI"/>
                             </constraints>
@@ -32,7 +32,7 @@
                             </connections>
                         </button>
                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cjh-je-E6h">
-                            <rect key="frame" x="119" y="10" width="101" height="40"/>
+                            <rect key="frame" x="119" y="11" width="101" height="40"/>
                             <constraints>
                                 <constraint firstAttribute="height" constant="40" id="Zjv-nS-ufy"/>
                             </constraints>
@@ -45,7 +45,7 @@
                             </connections>
                         </button>
                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Zta-tv-COt">
-                            <rect key="frame" x="230" y="10" width="101" height="40"/>
+                            <rect key="frame" x="230" y="11" width="101" height="40"/>
                             <constraints>
                                 <constraint firstAttribute="height" constant="40" id="Dm7-86-DVq"/>
                             </constraints>
@@ -60,7 +60,7 @@
                     </subviews>
                     <constraints>
                         <constraint firstItem="cjh-je-E6h" firstAttribute="leading" secondItem="Hie-dN-B9L" secondAttribute="trailing" constant="10" id="5aP-yP-Qrg"/>
-                        <constraint firstItem="Hie-dN-B9L" firstAttribute="top" secondItem="4m9-yf-RbB" secondAttribute="top" constant="10" id="6dq-TK-VJe"/>
+                        <constraint firstItem="Hie-dN-B9L" firstAttribute="top" secondItem="4m9-yf-RbB" secondAttribute="top" constant="11" id="6dq-TK-VJe"/>
                         <constraint firstItem="Zta-tv-COt" firstAttribute="leading" secondItem="cjh-je-E6h" secondAttribute="trailing" constant="10" id="6hB-av-smB"/>
                         <constraint firstItem="Zta-tv-COt" firstAttribute="centerY" secondItem="cjh-je-E6h" secondAttribute="centerY" id="Fcu-ai-2K5"/>
                         <constraint firstItem="Hie-dN-B9L" firstAttribute="leading" secondItem="4m9-yf-RbB" secondAttribute="leading" constant="10" id="GNB-In-2UC"/>
@@ -72,7 +72,7 @@
                     <rect key="frame" x="0.0" y="50" width="551" height="50"/>
                     <subviews>
                         <button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1LD-cd-zhc">
-                            <rect key="frame" x="10" y="15" width="25" height="25"/>
+                            <rect key="frame" x="10" y="12.5" width="25" height="25"/>
                             <constraints>
                                 <constraint firstAttribute="width" constant="25" id="D76-X9-Tw9"/>
                                 <constraint firstAttribute="height" constant="25" id="izT-Ru-XYG"/>
@@ -83,7 +83,7 @@
                             </connections>
                         </button>
                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0bo-yl-t5k">
-                            <rect key="frame" x="45" y="13.5" width="163" height="28"/>
+                            <rect key="frame" x="45" y="11" width="163" height="28"/>
                             <fontDescription key="fontDescription" type="system" pointSize="13"/>
                             <state key="normal" title="Sort by name (from A to Z)">
                                 <color key="titleColor" systemColor="darkTextColor"/>
@@ -93,7 +93,7 @@
                             </connections>
                         </button>
                         <button hidden="YES" opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="D0O-wK-14O">
-                            <rect key="frame" x="516" y="15" width="25" height="25"/>
+                            <rect key="frame" x="516" y="12.5" width="25" height="25"/>
                             <constraints>
                                 <constraint firstAttribute="width" constant="25" id="aEr-j8-JDO"/>
                                 <constraint firstAttribute="height" constant="25" id="bvx-Uh-NWD"/>
@@ -105,7 +105,7 @@
                         </button>
                     </subviews>
                     <constraints>
-                        <constraint firstAttribute="bottom" secondItem="1LD-cd-zhc" secondAttribute="bottom" constant="10" id="T2e-KO-lck"/>
+                        <constraint firstItem="1LD-cd-zhc" firstAttribute="centerY" secondItem="s4I-Jo-yCE" secondAttribute="centerY" id="9mz-E0-K4B"/>
                         <constraint firstItem="0bo-yl-t5k" firstAttribute="centerY" secondItem="1LD-cd-zhc" secondAttribute="centerY" id="URP-Ct-vPP"/>
                         <constraint firstItem="D0O-wK-14O" firstAttribute="centerY" secondItem="1LD-cd-zhc" secondAttribute="centerY" id="UUF-sF-n6M"/>
                         <constraint firstItem="0bo-yl-t5k" firstAttribute="leading" secondItem="1LD-cd-zhc" secondAttribute="trailing" constant="10" id="VBJ-H7-cJ3"/>

+ 3 - 1
iOSClient/Offline/NCOffline.swift

@@ -33,7 +33,9 @@ class NCOffline: NCCollectionViewCommon {
 
         titleCurrentFolder = NSLocalizedString("_manage_file_offline_", comment: "")
         layoutKey = NCGlobal.shared.layoutViewOffline
-        enableSearchBar = true
+        enableSearchBar = false
+        headerMenuButtonsCommand = false
+        headerMenuButtonsView = true
         emptyImage = UIImage(named: "folder")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width)
         emptyTitle = "_files_no_files_"
         emptyDescription = "_tutorial_offline_view_"

+ 4 - 4
iOSClient/Select/NCSelect.swift

@@ -118,7 +118,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
         bottomContraint?.constant = UIApplication.shared.keyWindow?.rootViewController?.view.safeAreaInsets.bottom ?? 0
 
         // Empty
-        emptyDataSet = NCEmptyDataSet(view: collectionView, offset: NCGlobal.shared.heightButtonsCommand + NCGlobal.shared.heightButtonsView, delegate: self)
+        emptyDataSet = NCEmptyDataSet(view: collectionView, offset: NCGlobal.shared.heightButtonsView, delegate: self)
 
         // Type of command view
         if typeOfCommandView == .select || typeOfCommandView == .selectCreateFolder {
@@ -624,7 +624,7 @@ extension NCSelect: UICollectionViewDataSource {
                 header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath).firstUppercased
                 header.labelSection.textColor = NCBrandColor.shared.brandElement
 
-                header.setButtonsCommand(heigt: NCGlobal.shared.heightButtonsCommand)
+                header.setButtonsCommand(heigt: 0)
                 header.setButtonsView(heigt: NCGlobal.shared.heightButtonsView)
                 header.setRichWorkspaceHeight(heightHeaderRichWorkspace)
                 header.setSectionHeight(heightHeaderSection)
@@ -671,9 +671,9 @@ extension NCSelect: UICollectionViewDelegateFlowLayout {
         }
 
         if section == 0 && dataSource.numberOfSections() > 1 {
-            return (NCGlobal.shared.heightButtonsCommand + NCGlobal.shared.heightButtonsView, headerRichWorkspace, NCGlobal.shared.heightSection)
+            return (NCGlobal.shared.heightButtonsView, headerRichWorkspace, NCGlobal.shared.heightSection)
         } else if section == 0 && dataSource.numberOfSections() == 1 {
-            return (NCGlobal.shared.heightButtonsCommand + NCGlobal.shared.heightButtonsView, headerRichWorkspace, 0)
+            return (NCGlobal.shared.heightButtonsView, headerRichWorkspace, 0)
         } else if section > 0 && dataSource.numberOfSections() > 1 {
             return (0, 0, NCGlobal.shared.heightSection)
         } else {

+ 2 - 0
iOSClient/Shares/NCShares.swift

@@ -34,6 +34,8 @@ class NCShares: NCCollectionViewCommon {
         titleCurrentFolder = NSLocalizedString("_list_shares_", comment: "")
         layoutKey = NCGlobal.shared.layoutViewShares
         enableSearchBar = false
+        headerMenuButtonsCommand = false
+        headerMenuButtonsView = true
         emptyImage = UIImage(named: "share")?.image(color: .gray, size: UIScreen.main.bounds.width)
         emptyTitle = "_list_shares_no_files_"
         emptyDescription = "_tutorial_list_shares_view_"