|
@@ -26,7 +26,7 @@ import SwiftUI
|
|
|
import NextcloudKit
|
|
|
|
|
|
@objc protocol NCSelectDelegate {
|
|
|
- @objc func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], overwrite: Bool, copy: Bool, move: Bool)
|
|
|
+ @objc func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], indexPath: [IndexPath], overwrite: Bool, copy: Bool, move: Bool)
|
|
|
}
|
|
|
|
|
|
class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresentationControllerDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, NCEmptyDataSetDelegate {
|
|
@@ -53,6 +53,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
@objc var enableSelectFile = false
|
|
|
@objc var type = ""
|
|
|
@objc var items: [tableMetadata] = []
|
|
|
+ @objc var selectIndexPath: [IndexPath] = []
|
|
|
|
|
|
var titleCurrentFolder = NCBrandOptions.shared.brand
|
|
|
var serverUrl = ""
|
|
@@ -60,28 +61,20 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
|
|
|
private var emptyDataSet: NCEmptyDataSet?
|
|
|
|
|
|
- private let layoutKey = NCGlobal.shared.layoutViewMove
|
|
|
private var serverUrlPush = ""
|
|
|
private var metadataFolder = tableMetadata()
|
|
|
|
|
|
- private var isEditMode = false
|
|
|
- private var isSearching = false
|
|
|
private var networkInProgress = false
|
|
|
- private var selectOcId: [String] = []
|
|
|
private var overwrite = true
|
|
|
|
|
|
private var dataSource = NCDataSource()
|
|
|
internal var richWorkspaceText: String?
|
|
|
|
|
|
- private var layoutForView: NCDBLayoutForView?
|
|
|
internal var headerMenu: NCSectionHeaderMenu?
|
|
|
|
|
|
private var autoUploadFileName = ""
|
|
|
private var autoUploadDirectory = ""
|
|
|
|
|
|
- private var listLayout: NCListLayout!
|
|
|
- private var gridLayout: NCGridLayout!
|
|
|
-
|
|
|
private var backgroundImageView = UIImageView()
|
|
|
|
|
|
private var activeAccount: tableAccount!
|
|
@@ -102,7 +95,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
|
|
|
// Cell
|
|
|
collectionView.register(UINib(nibName: "NCListCell", bundle: nil), forCellWithReuseIdentifier: "listCell")
|
|
|
- collectionView.register(UINib(nibName: "NCGridCell", bundle: nil), forCellWithReuseIdentifier: "gridCell")
|
|
|
+ collectionView.collectionViewLayout = NCListLayout()
|
|
|
|
|
|
// Header
|
|
|
collectionView.register(UINib(nibName: "NCSectionHeaderMenu", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "sectionHeaderMenu")
|
|
@@ -112,9 +105,6 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
collectionView.alwaysBounceVertical = true
|
|
|
collectionView.backgroundColor = .systemBackground
|
|
|
|
|
|
- listLayout = NCListLayout()
|
|
|
- gridLayout = NCGridLayout()
|
|
|
-
|
|
|
buttonCancel.title = NSLocalizedString("_cancel_", comment: "")
|
|
|
|
|
|
bottomContraint?.constant = window?.rootViewController?.view.safeAreaInsets.bottom ?? 0
|
|
@@ -176,15 +166,6 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
autoUploadFileName = NCManageDatabase.shared.getAccountAutoUploadFileName()
|
|
|
autoUploadDirectory = NCManageDatabase.shared.getAccountAutoUploadDirectory(urlBase: activeAccount.urlBase, userId: activeAccount.userId, account: activeAccount.account)
|
|
|
|
|
|
- layoutForView = NCManageDatabase.shared.getLayoutForView(account: activeAccount.account, key: layoutKey, serverUrl: serverUrl)
|
|
|
- gridLayout.itemForLine = CGFloat(layoutForView?.itemForLine ?? 3)
|
|
|
-
|
|
|
- if layoutForView?.layout == NCGlobal.shared.layoutList {
|
|
|
- collectionView.collectionViewLayout = listLayout
|
|
|
- } else {
|
|
|
- collectionView.collectionViewLayout = gridLayout
|
|
|
- }
|
|
|
-
|
|
|
loadDatasource(withLoadFolder: true)
|
|
|
}
|
|
|
|
|
@@ -240,17 +221,17 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
}
|
|
|
|
|
|
func selectButtonPressed(_ sender: UIButton) {
|
|
|
- delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadataFolder, type: type, items: items, overwrite: overwrite, copy: false, move: false)
|
|
|
+ delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadataFolder, type: type, items: items, indexPath: selectIndexPath, overwrite: overwrite, copy: false, move: false)
|
|
|
self.dismiss(animated: true, completion: nil)
|
|
|
}
|
|
|
|
|
|
func copyButtonPressed(_ sender: UIButton) {
|
|
|
- delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadataFolder, type: type, items: items, overwrite: overwrite, copy: true, move: false)
|
|
|
+ delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadataFolder, type: type, items: items, indexPath: selectIndexPath, overwrite: overwrite, copy: true, move: false)
|
|
|
self.dismiss(animated: true, completion: nil)
|
|
|
}
|
|
|
|
|
|
func moveButtonPressed(_ sender: UIButton) {
|
|
|
- delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadataFolder, type: type, items: items, overwrite: overwrite, copy: false, move: true)
|
|
|
+ delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadataFolder, type: type, items: items, indexPath: selectIndexPath, overwrite: overwrite, copy: false, move: true)
|
|
|
self.dismiss(animated: true, completion: nil)
|
|
|
}
|
|
|
|
|
@@ -263,40 +244,6 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
overwrite = sender.isOn
|
|
|
}
|
|
|
|
|
|
- // MARK: TAP EVENT
|
|
|
-
|
|
|
- func tapButtonSwitch(_ sender: Any) {
|
|
|
-
|
|
|
- if layoutForView?.layout == NCGlobal.shared.layoutGrid {
|
|
|
-
|
|
|
- // list layout
|
|
|
- headerMenu?.buttonSwitch.accessibilityLabel = NSLocalizedString("_grid_view_", comment: "")
|
|
|
- layoutForView?.layout = NCGlobal.shared.layoutList
|
|
|
- NCManageDatabase.shared.setLayoutForView(account: activeAccount.account, key: layoutKey, serverUrl: serverUrl, layout: layoutForView?.layout)
|
|
|
-
|
|
|
- self.collectionView.reloadData()
|
|
|
- self.collectionView.collectionViewLayout.invalidateLayout()
|
|
|
- self.collectionView.setCollectionViewLayout(self.listLayout, animated: true)
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- // grid layout
|
|
|
- headerMenu?.buttonSwitch.accessibilityLabel = NSLocalizedString("_list_view_", comment: "")
|
|
|
- layoutForView?.layout = NCGlobal.shared.layoutGrid
|
|
|
- NCManageDatabase.shared.setLayoutForView(account: activeAccount.account, key: layoutKey, serverUrl: serverUrl, layout: layoutForView?.layout)
|
|
|
-
|
|
|
- self.collectionView.reloadData()
|
|
|
- self.collectionView.collectionViewLayout.invalidateLayout()
|
|
|
- self.collectionView.setCollectionViewLayout(self.gridLayout, animated: true)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- func tapButtonOrder(_ sender: Any) {
|
|
|
-
|
|
|
- let sortMenu = NCSortMenu()
|
|
|
- sortMenu.toggleMenu(viewController: self, account: activeAccount.account, key: layoutKey, sortButton: sender as? UIButton, serverUrl: serverUrl)
|
|
|
- }
|
|
|
-
|
|
|
// MARK: - Push metadata
|
|
|
|
|
|
func pushMetadata(_ metadata: tableMetadata) {
|
|
@@ -314,6 +261,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
|
|
|
viewController.type = type
|
|
|
viewController.overwrite = overwrite
|
|
|
viewController.items = items
|
|
|
+ viewController.selectIndexPath = selectIndexPath
|
|
|
|
|
|
viewController.titleCurrentFolder = metadata.fileNameView
|
|
|
viewController.serverUrl = serverUrlPush
|
|
@@ -330,23 +278,13 @@ extension NCSelect: UICollectionViewDelegate {
|
|
|
|
|
|
guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return }
|
|
|
|
|
|
- if isEditMode {
|
|
|
- if let index = selectOcId.firstIndex(of: metadata.ocId) {
|
|
|
- selectOcId.remove(at: index)
|
|
|
- } else {
|
|
|
- selectOcId.append(metadata.ocId)
|
|
|
- }
|
|
|
- collectionView.reloadItems(at: [indexPath])
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
if metadata.directory {
|
|
|
|
|
|
pushMetadata(metadata)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadata, type: type, items: items, overwrite: overwrite, copy: false, move: false)
|
|
|
+ delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadata, type: type, items: items, indexPath: selectIndexPath, overwrite: overwrite, copy: false, move: false)
|
|
|
self.dismiss(animated: true, completion: nil)
|
|
|
}
|
|
|
}
|
|
@@ -393,11 +331,7 @@ extension NCSelect: UICollectionViewDataSource {
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
|
|
|
|
guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else {
|
|
|
- if layoutForView?.layout == NCGlobal.shared.layoutList {
|
|
|
- return collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
|
|
|
- } else {
|
|
|
- return collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell
|
|
|
- }
|
|
|
+ return collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
|
|
|
}
|
|
|
|
|
|
var isShare = false
|
|
@@ -406,227 +340,105 @@ extension NCSelect: UICollectionViewDataSource {
|
|
|
isShare = metadata.permissions.contains(NCGlobal.shared.permissionShared) && !metadataFolder.permissions.contains(NCGlobal.shared.permissionShared)
|
|
|
isMounted = metadata.permissions.contains(NCGlobal.shared.permissionMounted) && !metadataFolder.permissions.contains(NCGlobal.shared.permissionMounted)
|
|
|
|
|
|
- // LAYOUT LIST
|
|
|
-
|
|
|
- if layoutForView?.layout == NCGlobal.shared.layoutList {
|
|
|
-
|
|
|
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
|
|
|
- cell.delegate = self
|
|
|
-
|
|
|
- cell.fileObjectId = metadata.ocId
|
|
|
- cell.fileUser = metadata.ownerId
|
|
|
- cell.labelTitle.text = metadata.fileNameView
|
|
|
- cell.labelTitle.textColor = .label
|
|
|
-
|
|
|
- cell.imageSelect.image = nil
|
|
|
- cell.imageStatus.image = nil
|
|
|
- cell.imageLocal.image = nil
|
|
|
- cell.imageFavorite.image = nil
|
|
|
- cell.imageShared.image = nil
|
|
|
- cell.imageMore.image = nil
|
|
|
-
|
|
|
- cell.imageItem.image = nil
|
|
|
- cell.imageItem.backgroundColor = nil
|
|
|
-
|
|
|
- cell.progressView.progress = 0.0
|
|
|
-
|
|
|
- if metadata.directory {
|
|
|
-
|
|
|
- if metadata.e2eEncrypted {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderEncrypted
|
|
|
- } else if isShare {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe
|
|
|
- } else if !metadata.shareType.isEmpty {
|
|
|
- metadata.shareType.contains(3) ?
|
|
|
- (cell.imageItem.image = NCBrandColor.cacheImages.folderPublic) :
|
|
|
- (cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe)
|
|
|
- } else if metadata.mountType == "group" {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderGroup
|
|
|
- } else if isMounted {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderExternal
|
|
|
- } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderAutomaticUpload
|
|
|
- } else {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folder
|
|
|
- }
|
|
|
- cell.imageItem.image = cell.imageItem.image?.colorizeFolder(metadata: metadata)
|
|
|
-
|
|
|
- cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
|
|
|
+ let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
|
|
|
+ cell.delegate = self
|
|
|
|
|
|
- } else {
|
|
|
+ cell.fileObjectId = metadata.ocId
|
|
|
+ cell.fileUser = metadata.ownerId
|
|
|
+ cell.labelTitle.text = metadata.fileNameView
|
|
|
+ cell.labelTitle.textColor = .label
|
|
|
|
|
|
- cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
|
|
|
+ cell.imageSelect.image = nil
|
|
|
+ cell.imageStatus.image = nil
|
|
|
+ cell.imageLocal.image = nil
|
|
|
+ cell.imageFavorite.image = nil
|
|
|
+ cell.imageShared.image = nil
|
|
|
+ cell.imageMore.image = nil
|
|
|
|
|
|
- // image local
|
|
|
- if dataSource.metadatasForSection[indexPath.section].metadataOffLine.contains(metadata.ocId) {
|
|
|
- cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
|
|
|
- } else if CCUtility.fileProviderStorageExists(metadata) {
|
|
|
- cell.imageLocal.image = NCBrandColor.cacheImages.local
|
|
|
- }
|
|
|
- }
|
|
|
+ cell.imageItem.image = nil
|
|
|
+ cell.imageItem.backgroundColor = nil
|
|
|
|
|
|
- // image Favorite
|
|
|
- if metadata.favorite {
|
|
|
- cell.imageFavorite.image = NCBrandColor.cacheImages.favorite
|
|
|
- }
|
|
|
+ cell.progressView.progress = 0.0
|
|
|
|
|
|
- // Share image
|
|
|
- if isShare {
|
|
|
- cell.imageShared.image = NCBrandColor.cacheImages.shared
|
|
|
+ if metadata.directory {
|
|
|
+
|
|
|
+ if metadata.e2eEncrypted {
|
|
|
+ cell.imageItem.image = NCBrandColor.cacheImages.folderEncrypted
|
|
|
+ } else if isShare {
|
|
|
+ cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe
|
|
|
} else if !metadata.shareType.isEmpty {
|
|
|
metadata.shareType.contains(3) ?
|
|
|
- (cell.imageShared.image = NCBrandColor.cacheImages.shareByLink) :
|
|
|
- (cell.imageShared.image = NCBrandColor.cacheImages.shared)
|
|
|
+ (cell.imageItem.image = NCBrandColor.cacheImages.folderPublic) :
|
|
|
+ (cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe)
|
|
|
+ } else if metadata.mountType == "group" {
|
|
|
+ cell.imageItem.image = NCBrandColor.cacheImages.folderGroup
|
|
|
+ } else if isMounted {
|
|
|
+ cell.imageItem.image = NCBrandColor.cacheImages.folderExternal
|
|
|
+ } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory {
|
|
|
+ cell.imageItem.image = NCBrandColor.cacheImages.folderAutomaticUpload
|
|
|
} else {
|
|
|
- cell.imageShared.image = NCBrandColor.cacheImages.canShare
|
|
|
+ cell.imageItem.image = NCBrandColor.cacheImages.folder
|
|
|
}
|
|
|
+ cell.imageItem.image = cell.imageItem.image?.colorizeFolder(metadata: metadata)
|
|
|
|
|
|
- cell.imageSelect.isHidden = true
|
|
|
- cell.backgroundView = nil
|
|
|
- cell.hideButtonMore(true)
|
|
|
- cell.hideButtonShare(true)
|
|
|
- cell.selectMode(false)
|
|
|
-
|
|
|
- // Live Photo
|
|
|
- if metadata.livePhoto {
|
|
|
- cell.imageStatus.image = NCBrandColor.cacheImages.livePhoto
|
|
|
- }
|
|
|
+ cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
|
|
|
|
|
|
- // Remove last separator
|
|
|
- if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 {
|
|
|
- cell.separator.isHidden = true
|
|
|
- } else {
|
|
|
- cell.separator.isHidden = false
|
|
|
- }
|
|
|
-
|
|
|
- // Add TAGS
|
|
|
- cell.setTags(tags: Array(metadata.tags))
|
|
|
-
|
|
|
- return cell
|
|
|
- }
|
|
|
-
|
|
|
- // LAYOUT GRID
|
|
|
-
|
|
|
- if layoutForView?.layout == NCGlobal.shared.layoutGrid {
|
|
|
-
|
|
|
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell
|
|
|
- cell.delegate = self
|
|
|
-
|
|
|
- cell.fileObjectId = metadata.ocId
|
|
|
- cell.fileUser = metadata.ownerId
|
|
|
- cell.labelTitle.text = metadata.fileNameView
|
|
|
- cell.labelTitle.textColor = .label
|
|
|
-
|
|
|
- cell.imageSelect.image = nil
|
|
|
- cell.imageStatus.image = nil
|
|
|
- cell.imageLocal.image = nil
|
|
|
- cell.imageFavorite.image = nil
|
|
|
-
|
|
|
- cell.imageItem.image = nil
|
|
|
- cell.imageItem.backgroundColor = nil
|
|
|
-
|
|
|
- cell.progressView.progress = 0.0
|
|
|
-
|
|
|
- if metadata.directory {
|
|
|
-
|
|
|
- if metadata.e2eEncrypted {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderEncrypted
|
|
|
- } else if isShare {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe
|
|
|
- } else if !metadata.shareType.isEmpty {
|
|
|
- metadata.shareType.contains(3) ?
|
|
|
- (cell.imageItem.image = NCBrandColor.cacheImages.folderPublic) :
|
|
|
- (cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe)
|
|
|
- } else if metadata.mountType == "group" {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderGroup
|
|
|
- } else if isMounted {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderExternal
|
|
|
- } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderAutomaticUpload
|
|
|
- } else {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folder
|
|
|
- }
|
|
|
- cell.imageItem.image = cell.imageItem.image?.colorizeFolder(metadata: metadata)
|
|
|
+ } else {
|
|
|
|
|
|
- } else {
|
|
|
+ cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
|
|
|
|
|
|
- // image Local
|
|
|
- if dataSource.metadatasForSection[indexPath.section].metadataOffLine.contains(metadata.ocId) {
|
|
|
- cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
|
|
|
- } else if CCUtility.fileProviderStorageExists(metadata) {
|
|
|
- cell.imageLocal.image = NCBrandColor.cacheImages.local
|
|
|
- }
|
|
|
+ // image local
|
|
|
+ if NCManageDatabase.shared.getTableLocalFile(ocId: metadata.ocId) != nil {
|
|
|
+ cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
|
|
|
+ } else if CCUtility.fileProviderStorageExists(metadata) {
|
|
|
+ cell.imageLocal.image = NCBrandColor.cacheImages.local
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // image Favorite
|
|
|
- if metadata.favorite {
|
|
|
- cell.imageFavorite.image = NCBrandColor.cacheImages.favorite
|
|
|
- }
|
|
|
+ // image Favorite
|
|
|
+ if metadata.favorite {
|
|
|
+ cell.imageFavorite.image = NCBrandColor.cacheImages.favorite
|
|
|
+ }
|
|
|
|
|
|
- cell.imageSelect.isHidden = true
|
|
|
- cell.backgroundView = nil
|
|
|
- cell.hideButtonMore(true)
|
|
|
+ cell.imageSelect.isHidden = true
|
|
|
+ cell.backgroundView = nil
|
|
|
+ cell.hideButtonMore(true)
|
|
|
+ cell.hideButtonShare(true)
|
|
|
+ cell.selectMode(false)
|
|
|
|
|
|
- // Live Photo
|
|
|
- if metadata.livePhoto {
|
|
|
- cell.imageStatus.image = NCBrandColor.cacheImages.livePhoto
|
|
|
- }
|
|
|
+ // Live Photo
|
|
|
+ if metadata.livePhoto {
|
|
|
+ cell.imageStatus.image = NCBrandColor.cacheImages.livePhoto
|
|
|
+ }
|
|
|
|
|
|
- return cell
|
|
|
+ // Remove last separator
|
|
|
+ if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 {
|
|
|
+ cell.separator.isHidden = true
|
|
|
+ } else {
|
|
|
+ cell.separator.isHidden = false
|
|
|
}
|
|
|
|
|
|
- return collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell
|
|
|
+ // Add TAGS
|
|
|
+ cell.setTags(tags: Array(metadata.tags))
|
|
|
+
|
|
|
+ return cell
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
|
|
|
|
|
|
if kind == UICollectionView.elementKindSectionHeader {
|
|
|
|
|
|
- if indexPath.section == 0 {
|
|
|
-
|
|
|
- let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
|
|
|
- let (_, heightHeaderRichWorkspace, heightHeaderSection) = getHeaderHeight(section: indexPath.section)
|
|
|
-
|
|
|
- self.headerMenu = header
|
|
|
+ let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
|
|
|
+ let (_, heightHeaderRichWorkspace, _) = getHeaderHeight(section: indexPath.section)
|
|
|
|
|
|
- if layoutForView?.layout == NCGlobal.shared.layoutGrid {
|
|
|
- header.setImageSwitchList()
|
|
|
- header.buttonSwitch.accessibilityLabel = NSLocalizedString("_list_view_", comment: "")
|
|
|
- } else {
|
|
|
- header.setImageSwitchGrid()
|
|
|
- header.buttonSwitch.accessibilityLabel = NSLocalizedString("_grid_view_", comment: "")
|
|
|
- }
|
|
|
+ self.headerMenu = header
|
|
|
|
|
|
- header.delegate = self
|
|
|
-
|
|
|
- header.setButtonsView(height: NCGlobal.shared.heightButtonsView)
|
|
|
- header.setStatusButtonsView(enable: !dataSource.getMetadataSourceForAllSections().isEmpty)
|
|
|
- header.setSortedTitle(layoutForView?.titleButtonHeader ?? "")
|
|
|
-
|
|
|
- header.setRichWorkspaceHeight(heightHeaderRichWorkspace)
|
|
|
- header.setRichWorkspaceText(richWorkspaceText)
|
|
|
-
|
|
|
- header.setViewTransfer(isHidden: true)
|
|
|
-
|
|
|
- header.setSectionHeight(heightHeaderSection)
|
|
|
- if heightHeaderSection == 0 {
|
|
|
- header.labelSection.text = ""
|
|
|
- } else {
|
|
|
- header.labelSection.text = self.dataSource.getSectionValueLocalization(indexPath: indexPath)
|
|
|
- }
|
|
|
- header.labelSection.textColor = .label
|
|
|
-
|
|
|
- return header
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! NCSectionHeader
|
|
|
-
|
|
|
- header.labelSection.text = self.dataSource.getSectionValueLocalization(indexPath: indexPath)
|
|
|
- header.labelSection.textColor = NCBrandColor.shared.brandElement
|
|
|
-
|
|
|
- return header
|
|
|
- }
|
|
|
+ header.delegate = self
|
|
|
+ header.setButtonsView(height: 0)
|
|
|
+ header.setRichWorkspaceHeight(heightHeaderRichWorkspace)
|
|
|
+ header.setRichWorkspaceText(richWorkspaceText)
|
|
|
+ header.setViewTransfer(isHidden: true)
|
|
|
+ return header
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -657,20 +469,12 @@ extension NCSelect: UICollectionViewDelegateFlowLayout {
|
|
|
|
|
|
if let richWorkspaceText = richWorkspaceText {
|
|
|
let trimmed = richWorkspaceText.trimmingCharacters(in: .whitespaces)
|
|
|
- if trimmed.count > 0 && !isSearching {
|
|
|
+ if trimmed.count > 0 {
|
|
|
headerRichWorkspace = UIScreen.main.bounds.size.height / 6
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if isSearching || layoutForView?.layout == NCGlobal.shared.layoutGrid || dataSource.numberOfSections() > 1 {
|
|
|
- if section == 0 {
|
|
|
- return (NCGlobal.shared.heightButtonsView, headerRichWorkspace, NCGlobal.shared.heightSection)
|
|
|
- } else {
|
|
|
- return (0, 0, NCGlobal.shared.heightSection)
|
|
|
- }
|
|
|
- } else {
|
|
|
- return (NCGlobal.shared.heightButtonsView, headerRichWorkspace, 0)
|
|
|
- }
|
|
|
+ return (0, headerRichWorkspace, 0)
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
|
|
@@ -704,14 +508,6 @@ extension NCSelect {
|
|
|
@objc func loadDatasource(withLoadFolder: Bool) {
|
|
|
|
|
|
var predicate: NSPredicate?
|
|
|
- var groupByField = "name"
|
|
|
-
|
|
|
- layoutForView = NCManageDatabase.shared.getLayoutForView(account: activeAccount.account, key: layoutKey, serverUrl: serverUrl)
|
|
|
-
|
|
|
- // set GroupField for Grid
|
|
|
- if layoutForView?.layout == NCGlobal.shared.layoutGrid {
|
|
|
- groupByField = "classFile"
|
|
|
- }
|
|
|
|
|
|
if includeDirectoryE2EEncryption {
|
|
|
|
|
@@ -735,12 +531,12 @@ extension NCSelect {
|
|
|
let metadatas = NCManageDatabase.shared.getMetadatas(predicate: predicate!)
|
|
|
self.dataSource = NCDataSource(metadatas: metadatas,
|
|
|
account: activeAccount.account,
|
|
|
- sort: layoutForView?.sort,
|
|
|
- ascending: layoutForView?.ascending,
|
|
|
- directoryOnTop: layoutForView?.directoryOnTop,
|
|
|
+ sort: "fileName",
|
|
|
+ ascending: true,
|
|
|
+ directoryOnTop: true,
|
|
|
favoriteOnTop: true,
|
|
|
filterLivePhoto: true,
|
|
|
- groupByField: groupByField)
|
|
|
+ groupByField: "none")
|
|
|
|
|
|
if withLoadFolder {
|
|
|
loadFolder()
|
|
@@ -880,7 +676,7 @@ struct SelectView: UIViewControllerRepresentable {
|
|
|
self.parent = parent
|
|
|
}
|
|
|
|
|
|
- func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], overwrite: Bool, copy: Bool, move: Bool) {
|
|
|
+ func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], indexPath: [IndexPath], overwrite: Bool, copy: Bool, move: Bool) {
|
|
|
if let serverUrl = serverUrl {
|
|
|
self.parent.serverUrl = serverUrl
|
|
|
}
|