Browse Source

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 years ago
parent
commit
a5e658520b

+ 8 - 14
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -54,12 +54,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     internal var listLayout: NCListLayout!
     internal var gridLayout: NCGridLayout!
 
-    internal let heightButtonsCommand: CGFloat = 60
-    internal let heightButtonsView: CGFloat = 40
-    internal let heightSection: CGFloat = 50
-    internal let footerHeight: CGFloat = 0
-    internal let footerEndHeight: CGFloat = 100
-
     internal var literalSearch: String?
     internal var isSearching: Bool = false
 
@@ -121,7 +115,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         }
 
         // Empty
-        emptyDataSet = NCEmptyDataSet(view: collectionView, offset: heightButtonsCommand + heightButtonsView, delegate: self)
+        emptyDataSet = NCEmptyDataSet(view: collectionView, offset: NCGlobal.shared.heightButtonsCommand + NCGlobal.shared.heightButtonsView, delegate: self)
 
         // Long Press on CollectionView
         let longPressedGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressCollecationView(_:)))
@@ -1832,8 +1826,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath).firstUppercased
                 header.labelSection.textColor = NCBrandColor.shared.brandElement
 
-                header.setButtonsView(heigt: heightButtonsView)
-                header.setButtonsCommand(heigt: 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.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.setSectionHeight(heightHeaderSection)
 
@@ -1879,11 +1873,11 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
         }
 
         if section == 0 && dataSource.numberOfSections() > 1 {
-            return (heightButtonsCommand + heightButtonsView, headerRichWorkspace, heightSection)
+            return (NCGlobal.shared.heightButtonsCommand + NCGlobal.shared.heightButtonsView, headerRichWorkspace, NCGlobal.shared.heightSection)
         } else if section == 0 && dataSource.numberOfSections() == 1 {
-            return (heightButtonsCommand + heightButtonsView, headerRichWorkspace, 0)
+            return (NCGlobal.shared.heightButtonsCommand + NCGlobal.shared.heightButtonsView, headerRichWorkspace, 0)
         } else if section > 0 && dataSource.numberOfSections() > 1 {
-            return (0, 0, heightSection)
+            return (0, 0, NCGlobal.shared.heightSection)
         } else {
             return (0, 0, 0)
         }
@@ -1899,9 +1893,9 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
 
         if dataSource.numberOfSections() == 1 {
-            return CGSize(width: collectionView.frame.width, height: footerEndHeight)
+            return CGSize(width: collectionView.frame.width, height: NCGlobal.shared.endHeightFooter)
         } else {
-            return CGSize(width: collectionView.frame.width, height: footerHeight)
+            return CGSize(width: collectionView.frame.width, height: 0)
         }
     }
 }

+ 12 - 6
iOSClient/Main/Section Header Footer/NCSectionHeaderFooter.swift

@@ -159,6 +159,12 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
 
     // Command
 
+    func setStatusButtonsCommand(enable: Bool) {
+        button1.isEnabled = enable
+        button2.isEnabled = enable
+        button3.isEnabled = enable
+    }
+
     func setButtonsCommand(heigt :CGFloat, imageButton1: UIImage? = nil, titleButton1: String? = nil, imageButton2: UIImage? = nil, titleButton2: String? = nil, imageButton3: UIImage? = nil, titleButton3: String? = nil) {
         viewButtonsCommandHeightConstraint.constant = heigt
         if heigt == 0 {
@@ -188,6 +194,12 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
 
     // View
 
+    func setStatusButtonsView(enable: Bool) {
+        buttonSwitch.isEnabled = enable
+        buttonOrder.isEnabled = enable
+        buttonMore.isEnabled = enable
+    }
+
     func buttonMoreIsHidden(_ isHidden: Bool) {
         buttonMore.isHidden = isHidden
     }
@@ -200,12 +212,6 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         buttonSwitch.setImage(UIImage(named: "switchGrid")!.image(color: NCBrandColor.shared.systemGray1, size: 50), for: .normal)
     }
 
-    func setStatusButtonsView(enable: Bool) {
-        buttonSwitch.isEnabled = enable
-        buttonOrder.isEnabled = enable
-        buttonMore.isEnabled = enable
-    }
-
     func setButtonsView(heigt :CGFloat) {
         viewButtonsViewHeightConstraint.constant = heigt
         if heigt == 0 {

+ 8 - 0
iOSClient/NCGlobal.swift

@@ -181,6 +181,14 @@ class NCGlobal: NSObject {
     let buttonMoreStop                              = "stop"
     let buttonMoreLock                              = "moreLock"
 
+    //
+    let heightButtonsCommand: CGFloat               = 60
+    let heightButtonsView: CGFloat                  = 40
+    let heightSection: CGFloat                      = 50
+    //let footerHeight: CGFloat                     = 0
+    let endHeightFooter: CGFloat                    = 100
+
+
     // Text -  OnlyOffice - Collabora - QuickLook
     //
     let editorText                                  = "text"

+ 8 - 14
iOSClient/Select/NCSelect.swift

@@ -80,12 +80,6 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
     private var listLayout: NCListLayout!
     private var gridLayout: NCGridLayout!
 
-    private let heightButtonsCommand: CGFloat = 0
-    private let heightButtonsView: CGFloat = 40
-    private let heightSection: CGFloat = 50
-    private let footerHeight: CGFloat = 0
-    private let footerEndHeight: CGFloat = 100
-
     private var shares: [tableShare]?
 
     private var backgroundImageView = UIImageView()
@@ -124,7 +118,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
         bottomContraint?.constant = UIApplication.shared.keyWindow?.rootViewController?.view.safeAreaInsets.bottom ?? 0
 
         // Empty
-        emptyDataSet = NCEmptyDataSet(view: collectionView, offset: heightButtonsCommand + heightButtonsView, delegate: self)
+        emptyDataSet = NCEmptyDataSet(view: collectionView, offset: NCGlobal.shared.heightButtonsCommand + NCGlobal.shared.heightButtonsView, delegate: self)
 
         // Type of command view
         if typeOfCommandView == .select || typeOfCommandView == .selectCreateFolder {
@@ -630,8 +624,8 @@ extension NCSelect: UICollectionViewDataSource {
                 header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath).firstUppercased
                 header.labelSection.textColor = NCBrandColor.shared.brandElement
 
-                header.setButtonsCommand(heigt: heightButtonsCommand)
-                header.setButtonsView(heigt: heightButtonsView)
+                header.setButtonsCommand(heigt: NCGlobal.shared.heightButtonsCommand)
+                header.setButtonsView(heigt: NCGlobal.shared.heightButtonsView)
                 header.setRichWorkspaceHeight(heightHeaderRichWorkspace)
                 header.setSectionHeight(heightHeaderSection)
 
@@ -677,11 +671,11 @@ extension NCSelect: UICollectionViewDelegateFlowLayout {
         }
 
         if section == 0 && dataSource.numberOfSections() > 1 {
-            return (heightButtonsCommand + heightButtonsView, headerRichWorkspace, heightSection)
+            return (NCGlobal.shared.heightButtonsCommand + NCGlobal.shared.heightButtonsView, headerRichWorkspace, NCGlobal.shared.heightSection)
         } else if section == 0 && dataSource.numberOfSections() == 1 {
-            return (heightButtonsCommand + heightButtonsView, headerRichWorkspace, 0)
+            return (NCGlobal.shared.heightButtonsCommand + NCGlobal.shared.heightButtonsView, headerRichWorkspace, 0)
         } else if section > 0 && dataSource.numberOfSections() > 1 {
-            return (0, 0, heightSection)
+            return (0, 0, NCGlobal.shared.heightSection)
         } else {
             return (0, 0, 0)
         }
@@ -697,9 +691,9 @@ extension NCSelect: UICollectionViewDelegateFlowLayout {
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
 
         if dataSource.numberOfSections() == 1 {
-            return CGSize(width: collectionView.frame.width, height: footerEndHeight)
+            return CGSize(width: collectionView.frame.width, height: NCGlobal.shared.endHeightFooter)
         } else {
-            return CGSize(width: collectionView.frame.width, height: footerHeight)
+            return CGSize(width: collectionView.frame.width, height: 0)
         }
     }
 }

+ 4 - 4
iOSClient/Trash/NCTrash+CollectionView.swift

@@ -158,10 +158,10 @@ extension NCTrash: UICollectionViewDataSource {
             header.buttonMoreIsHidden(false)
             header.setStatusButtonsView(enable: !datasource.isEmpty)
             header.setSortedTitle(layoutForView?.titleButtonHeader ?? "")
-            header.setButtonsCommand(heigt: heightButtonsCommand,
+            header.setButtonsCommand(heigt: NCGlobal.shared.heightButtonsCommand,
                                      imageButton1: UIImage(named: "restore"), titleButton1: NSLocalizedString("_trash_restore_selected_", comment: ""),
                                      imageButton2: UIImage(named: "trash"), titleButton2: NSLocalizedString("_trash_delete_selected_", comment: ""))
-            header.setButtonsView(heigt: heightButtonsView)
+            header.setButtonsView(heigt: NCGlobal.shared.heightButtonsView)
             header.setRichWorkspaceHeight(0)
             header.setSectionHeight(0)
 
@@ -183,10 +183,10 @@ extension NCTrash: UICollectionViewDataSource {
 extension NCTrash: UICollectionViewDelegateFlowLayout {
 
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
-        return CGSize(width: collectionView.frame.width, height: heightButtonsView + heightButtonsCommand)
+        return CGSize(width: collectionView.frame.width, height: NCGlobal.shared.heightButtonsView + NCGlobal.shared.heightButtonsCommand)
     }
 
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
-        return CGSize(width: collectionView.frame.width, height: footerEndHeight)
+        return CGSize(width: collectionView.frame.width, height: NCGlobal.shared.endHeightFooter)
     }
 }

+ 2 - 6
iOSClient/Trash/NCTrash.swift

@@ -47,10 +47,6 @@ class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDele
     var listLayout: NCListLayout!
     var gridLayout: NCGridLayout!
 
-    internal let heightButtonsCommand: CGFloat = 60
-    internal let heightButtonsView: CGFloat = 40
-    internal let footerEndHeight: CGFloat = 100
-
     private let refreshControl = UIRefreshControl()
 
     // MARK: - View Life Cycle
@@ -80,7 +76,7 @@ class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDele
         refreshControl.addTarget(self, action: #selector(loadListingTrash), for: .valueChanged)
 
         // Empty
-        emptyDataSet = NCEmptyDataSet(view: collectionView, offset: heightButtonsView, delegate: self)
+        emptyDataSet = NCEmptyDataSet(view: collectionView, offset: NCGlobal.shared.heightButtonsView + NCGlobal.shared.heightButtonsCommand, delegate: self)
 
         NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSource), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterReloadDataSource), object: nil)
@@ -202,7 +198,7 @@ class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDele
             let buttonPosition = button.convert(CGPoint.zero, to: collectionView)
             let indexPath = collectionView.indexPathForItem(at: buttonPosition)
             collectionView(self.collectionView, didSelectItemAt: indexPath!)
-        } // else: undefined sender
+        }
     }
 
     func tapButton1(_ sender: Any) {