|
@@ -54,8 +54,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
internal var listLayout: NCListLayout!
|
|
|
internal var gridLayout: NCGridLayout!
|
|
|
|
|
|
- private let headerHeight: CGFloat = 50
|
|
|
- private var headerRichWorkspaceHeight: CGFloat = 0
|
|
|
+ let headerCommand: CGFloat = 50
|
|
|
+ let headerSection: CGFloat = 50
|
|
|
+
|
|
|
private let footerHeight: CGFloat = 0
|
|
|
private let footerEndHeight: CGFloat = 100
|
|
|
|
|
@@ -121,7 +122,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
}
|
|
|
|
|
|
// Empty
|
|
|
- emptyDataSet = NCEmptyDataSet(view: collectionView, offset: headerHeight, delegate: self)
|
|
|
+ emptyDataSet = NCEmptyDataSet(view: collectionView, offset: headerCommand, delegate: self)
|
|
|
|
|
|
// Long Press on CollectionView
|
|
|
let longPressedGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressCollecationView(_:)))
|
|
@@ -676,6 +677,28 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
return userAlias
|
|
|
}
|
|
|
|
|
|
+ func getHeaderHeight(section:Int) -> (heightHeaderCommand: CGFloat, heightHeaderRichWorkspace: CGFloat, heightHeaderSection: CGFloat) {
|
|
|
+
|
|
|
+ var headerRichWorkspace: CGFloat = 0
|
|
|
+
|
|
|
+ if let richWorkspaceText = richWorkspaceText {
|
|
|
+ let trimmed = richWorkspaceText.trimmingCharacters(in: .whitespaces)
|
|
|
+ if trimmed.count > 0 && !isSearching {
|
|
|
+ headerRichWorkspace = UIScreen.main.bounds.size.height / 4
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if section == 0 && dataSource.numberOfSections() > 1 {
|
|
|
+ return (headerCommand, headerRichWorkspace, headerSection)
|
|
|
+ } else if section == 0 && dataSource.numberOfSections() == 1 {
|
|
|
+ return (headerCommand, headerRichWorkspace, 0)
|
|
|
+ } else if section > 1 && dataSource.numberOfSections() > 1 {
|
|
|
+ return (0, 0, headerSection)
|
|
|
+ } else {
|
|
|
+ return (0, 0, 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// MARK: - BackgroundImageColor Delegate
|
|
|
|
|
|
func colorPickerCancel() {
|
|
@@ -1310,56 +1333,6 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
|
|
|
|
|
|
extension NCCollectionViewCommon: UICollectionViewDataSource {
|
|
|
|
|
|
- func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
|
|
|
-
|
|
|
- if kind == UICollectionView.elementKindSectionHeader {
|
|
|
-
|
|
|
- if dataSource.numberOfSections() == 1 {
|
|
|
-
|
|
|
- let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
|
|
|
- self.headerMenu = header
|
|
|
-
|
|
|
- if collectionView.collectionViewLayout == gridLayout {
|
|
|
- header.buttonSwitch.setImage(UIImage(named: "switchList")!.image(color: NCBrandColor.shared.gray, size: 50), for: .normal)
|
|
|
- header.buttonSwitch.accessibilityLabel = NSLocalizedString("_list_view_", comment: "")
|
|
|
- } else {
|
|
|
- header.buttonSwitch.setImage(UIImage(named: "switchGrid")!.image(color: NCBrandColor.shared.gray, size: 50), for: .normal)
|
|
|
- header.buttonSwitch.accessibilityLabel = NSLocalizedString("_grid_view_", comment: "")
|
|
|
- }
|
|
|
-
|
|
|
- header.delegate = self
|
|
|
- header.setStatusButton(count: dataSource.metadatasSource.count)
|
|
|
- header.setTitleSorted(datasourceTitleButton: layoutForView?.titleButtonHeader ?? "")
|
|
|
- header.viewRichWorkspaceHeightConstraint.constant = headerRichWorkspaceHeight
|
|
|
- header.setRichWorkspaceText(richWorkspaceText: richWorkspaceText)
|
|
|
-
|
|
|
- return header
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! NCSectionHeader
|
|
|
-
|
|
|
- header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath).firstUppercased
|
|
|
- header.labelSection.textColor = NCBrandColor.shared.brandElement
|
|
|
-
|
|
|
- return header
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
|
|
|
-
|
|
|
- if dataSource.numberOfSections() == 1 {
|
|
|
- let info = dataSource.getFooterInformation()
|
|
|
- footer.setTitleLabel(directories: info.directories, files: info.files, size: info.size )
|
|
|
- } else {
|
|
|
- footer.setTitleLabel(text: "")
|
|
|
- }
|
|
|
-
|
|
|
- return footer
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
|
|
guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return }
|
|
|
|
|
@@ -1817,25 +1790,75 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
|
|
|
|
|
|
return collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
|
|
|
+ func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
|
|
|
|
|
|
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
|
|
|
+ if kind == UICollectionView.elementKindSectionHeader {
|
|
|
|
|
|
- headerRichWorkspaceHeight = 0
|
|
|
+ if indexPath.section == 0 {
|
|
|
|
|
|
- if let richWorkspaceText = richWorkspaceText {
|
|
|
- let trimmed = richWorkspaceText.trimmingCharacters(in: .whitespaces)
|
|
|
- if trimmed.count > 0 && !isSearching {
|
|
|
- headerRichWorkspaceHeight = UIScreen.main.bounds.size.height / 4
|
|
|
+ let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
|
|
|
+ let (_, heightHeaderRichWorkspace, heightHeaderSection) = getHeaderHeight(section: indexPath.section)
|
|
|
+
|
|
|
+ self.headerMenu = header
|
|
|
+
|
|
|
+ if collectionView.collectionViewLayout == gridLayout {
|
|
|
+ header.buttonSwitch.setImage(UIImage(named: "switchList")!.image(color: NCBrandColor.shared.gray, size: 50), for: .normal)
|
|
|
+ header.buttonSwitch.accessibilityLabel = NSLocalizedString("_list_view_", comment: "")
|
|
|
+ } else {
|
|
|
+ header.buttonSwitch.setImage(UIImage(named: "switchGrid")!.image(color: NCBrandColor.shared.gray, size: 50), for: .normal)
|
|
|
+ header.buttonSwitch.accessibilityLabel = NSLocalizedString("_grid_view_", comment: "")
|
|
|
+ }
|
|
|
+
|
|
|
+ header.delegate = self
|
|
|
+ header.setStatusButton(count: dataSource.metadatasSource.count)
|
|
|
+ header.setTitleSorted(datasourceTitleButton: layoutForView?.titleButtonHeader ?? "")
|
|
|
+ header.setRichWorkspaceText(richWorkspaceText: richWorkspaceText)
|
|
|
+ header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath).firstUppercased
|
|
|
+ header.labelSection.textColor = NCBrandColor.shared.brandElement
|
|
|
+
|
|
|
+ header.setRichWorkspaceHeight(heightHeaderRichWorkspace)
|
|
|
+ header.setSectionHeight(heightHeaderSection)
|
|
|
+
|
|
|
+ return header
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! NCSectionHeader
|
|
|
+
|
|
|
+ header.labelSection.text = self.dataSource.getSectionValue(indexPath: indexPath).firstUppercased
|
|
|
+ header.labelSection.textColor = NCBrandColor.shared.brandElement
|
|
|
+
|
|
|
+ return header
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
|
|
|
+
|
|
|
+ if dataSource.numberOfSections() == 1 {
|
|
|
+ let info = dataSource.getFooterInformation()
|
|
|
+ footer.setTitleLabel(directories: info.directories, files: info.files, size: info.size )
|
|
|
+ } else {
|
|
|
+ footer.setTitleLabel(text: "")
|
|
|
}
|
|
|
+
|
|
|
+ return footer
|
|
|
}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
|
|
|
|
|
|
- return CGSize(width: collectionView.frame.width, height: headerHeight + headerRichWorkspaceHeight)
|
|
|
+ func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
|
|
|
+
|
|
|
+ let (heightHeaderCommand, heightHeaderRichWorkspace, heightHeaderSection) = getHeaderHeight(section: section)
|
|
|
+
|
|
|
+ return CGSize(width: collectionView.frame.width, height: heightHeaderCommand + heightHeaderRichWorkspace + heightHeaderSection)
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
|
|
|
+
|
|
|
if dataSource.numberOfSections() == 1 {
|
|
|
return CGSize(width: collectionView.frame.width, height: footerEndHeight)
|
|
|
} else {
|