|
@@ -24,7 +24,7 @@
|
|
|
import Foundation
|
|
|
import NCCommunication
|
|
|
|
|
|
-class NCShareExtension: UIViewController, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, NCEmptyDataSetDelegate {
|
|
|
+class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDelegate {
|
|
|
|
|
|
@IBOutlet weak var collectionView: UICollectionView!
|
|
|
@IBOutlet weak var tableView: UITableView!
|
|
@@ -51,7 +51,6 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCGridCellDelegate
|
|
|
private var networkInProgress = false
|
|
|
|
|
|
private var dataSource = NCDataSource()
|
|
|
- internal var richWorkspaceText: String?
|
|
|
|
|
|
private var sort: String = ""
|
|
|
private var ascending: Bool = true
|
|
@@ -65,13 +64,7 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCGridCellDelegate
|
|
|
private var autoUploadDirectory = ""
|
|
|
|
|
|
private var listLayout: NCListLayout!
|
|
|
- private var gridLayout: NCGridLayout!
|
|
|
|
|
|
- private let headerHeight: CGFloat = 50
|
|
|
- private var headerRichWorkspaceHeight: CGFloat = 0
|
|
|
- private let footerHeight: CGFloat = 100
|
|
|
- private let heightCell: CGFloat = 50
|
|
|
-
|
|
|
private var shares: [tableShare]?
|
|
|
|
|
|
private let refreshControl = UIRefreshControl()
|
|
@@ -87,29 +80,18 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCGridCellDelegate
|
|
|
collectionView.register(UINib.init(nibName: "NCListCell", bundle: nil), forCellWithReuseIdentifier: "listCell")
|
|
|
collectionView.register(UINib.init(nibName: "NCGridCell", bundle: nil), forCellWithReuseIdentifier: "gridCell")
|
|
|
|
|
|
- // Header
|
|
|
- collectionView.register(UINib.init(nibName: "NCSectionHeaderMenu", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "sectionHeaderMenu")
|
|
|
-
|
|
|
- // Footer
|
|
|
- collectionView.register(UINib.init(nibName: "NCSectionFooter", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: "sectionFooter")
|
|
|
- collectionView.alwaysBounceVertical = true
|
|
|
-
|
|
|
listLayout = NCListLayout()
|
|
|
- gridLayout = NCGridLayout()
|
|
|
|
|
|
// Add Refresh Control
|
|
|
collectionView.addSubview(refreshControl)
|
|
|
refreshControl.tintColor = NCBrandColor.shared.brandText
|
|
|
refreshControl.backgroundColor = NCBrandColor.shared.backgroundView
|
|
|
- refreshControl.addTarget(self, action: #selector(loadDatasource), for: .valueChanged)
|
|
|
+ refreshControl.addTarget(self, action: #selector(reloadDatasource), for: .valueChanged)
|
|
|
|
|
|
// Empty
|
|
|
emptyDataSet = NCEmptyDataSet.init(view: collectionView, offset: 0, delegate: self)
|
|
|
|
|
|
separatorView.backgroundColor = NCBrandColor.shared.separator
|
|
|
-
|
|
|
- //createFolderButton.title = NSLocalizedString("_create_folder_", comment: "")
|
|
|
- //uploadButton.title = NSLocalizedString("_upload_", comment: "")
|
|
|
}
|
|
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
@@ -147,14 +129,9 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCGridCellDelegate
|
|
|
autoUploadDirectory = NCManageDatabase.shared.getAccountAutoUploadDirectory(urlBase: activeAccount.urlBase, account: activeAccount.account)
|
|
|
|
|
|
(layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: keyLayout,serverUrl: serverUrl)
|
|
|
- gridLayout.itemForLine = CGFloat(itemForLine)
|
|
|
-
|
|
|
- if layout == NCGlobal.shared.layoutList {
|
|
|
- collectionView.collectionViewLayout = listLayout
|
|
|
- } else {
|
|
|
- collectionView.collectionViewLayout = gridLayout
|
|
|
- }
|
|
|
|
|
|
+ collectionView.collectionViewLayout = listLayout
|
|
|
+
|
|
|
// Load data source
|
|
|
serverUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, account: activeAccount.account)
|
|
|
// ROOT load files
|
|
@@ -172,9 +149,7 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCGridCellDelegate
|
|
|
|
|
|
shares = NCManageDatabase.shared.getTableShares(account: activeAccount.account, serverUrl: serverUrl)
|
|
|
|
|
|
- loadDatasource(withLoadFolder: true)
|
|
|
-
|
|
|
- navigationButtons()
|
|
|
+ reloadDatasource(withLoadFolder: true)
|
|
|
}
|
|
|
|
|
|
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
|
@@ -197,13 +172,11 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCGridCellDelegate
|
|
|
|
|
|
// MARK: -
|
|
|
|
|
|
- func navigationButtons() {
|
|
|
+ func setNavigationBar() {
|
|
|
|
|
|
cancelButton.title = NSLocalizedString("_cancel_", comment: "")
|
|
|
-
|
|
|
- navigationItem.leftBarButtonItem = nil
|
|
|
navigationItem.title = titleCurrentFolder
|
|
|
-
|
|
|
+
|
|
|
// BACK BUTTON
|
|
|
|
|
|
let backButton = UIButton(type: .custom)
|
|
@@ -256,7 +229,6 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCGridCellDelegate
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// MARK: - Empty
|
|
|
|
|
|
func emptyDataSetView(_ view: NCEmptyView) {
|
|
@@ -314,62 +286,16 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCGridCellDelegate
|
|
|
|
|
|
}
|
|
|
|
|
|
- // MARK: TAP EVENT
|
|
|
-
|
|
|
- func tapSwitchHeader(sender: Any) {
|
|
|
-
|
|
|
- if collectionView.collectionViewLayout == gridLayout {
|
|
|
- // list layout
|
|
|
- UIView.animate(withDuration: 0.0, animations: {
|
|
|
- self.collectionView.collectionViewLayout.invalidateLayout()
|
|
|
- self.collectionView.setCollectionViewLayout(self.listLayout, animated: false, completion: { (_) in
|
|
|
- self.collectionView.reloadData()
|
|
|
- })
|
|
|
- })
|
|
|
- layout = NCGlobal.shared.layoutList
|
|
|
- } else {
|
|
|
- // grid layout
|
|
|
- UIView.animate(withDuration: 0.0, animations: {
|
|
|
- self.collectionView.collectionViewLayout.invalidateLayout()
|
|
|
- self.collectionView.setCollectionViewLayout(self.gridLayout, animated: false, completion: { (_) in
|
|
|
- self.collectionView.reloadData()
|
|
|
- })
|
|
|
- })
|
|
|
- layout = NCGlobal.shared.layoutGrid
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- func tapOrderHeader(sender: Any) {
|
|
|
-
|
|
|
- let sortMenu = NCSortMenu()
|
|
|
- sortMenu.toggleMenu(viewController: self, key: keyLayout, sortButton: sender as? UIButton, serverUrl: serverUrl)
|
|
|
- }
|
|
|
-
|
|
|
- func tapMoreHeader(sender: Any) {
|
|
|
- }
|
|
|
-
|
|
|
- func tapMoreListItem(with objectId: String, namedButtonMore: String, image: UIImage?, sender: Any) {
|
|
|
- }
|
|
|
-
|
|
|
- func tapMoreGridItem(with objectId: String, namedButtonMore: String, image: UIImage?, sender: Any) {
|
|
|
- }
|
|
|
-
|
|
|
func tapShareListItem(with objectId: String, sender: Any) {
|
|
|
}
|
|
|
|
|
|
- func tapRichWorkspace(sender: Any) {
|
|
|
- }
|
|
|
-
|
|
|
- func longPressListItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) {
|
|
|
- }
|
|
|
-
|
|
|
- func longPressGridItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) {
|
|
|
+ func tapMoreListItem(with objectId: String, namedButtonMore: String, image: UIImage?, sender: Any) {
|
|
|
}
|
|
|
|
|
|
func longPressMoreListItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) {
|
|
|
}
|
|
|
|
|
|
- func longPressMoreGridItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) {
|
|
|
+ func longPressListItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) {
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -383,6 +309,7 @@ extension NCShareExtension: UICollectionViewDelegate {
|
|
|
|
|
|
if metadata.directory {
|
|
|
|
|
|
+ /*
|
|
|
guard let serverUrlPush = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName) else { return }
|
|
|
guard let viewController = UIStoryboard(name: "MainInterface", bundle: nil).instantiateViewController(withIdentifier: "NCShareExtension.storyboard") as? NCShareExtension else { return }
|
|
|
|
|
@@ -394,44 +321,13 @@ extension NCShareExtension: UICollectionViewDelegate {
|
|
|
viewController.filesName = filesName
|
|
|
|
|
|
self.navigationController?.pushViewController(viewController, animated: true)
|
|
|
+ */
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
extension NCShareExtension: UICollectionViewDataSource {
|
|
|
|
|
|
- func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
|
|
|
-
|
|
|
- if kind == UICollectionView.elementKindSectionHeader {
|
|
|
-
|
|
|
- let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
|
|
|
-
|
|
|
- if collectionView.collectionViewLayout == gridLayout {
|
|
|
- header.buttonSwitch.setImage(UIImage.init(named: "switchList")?.image(color: NCBrandColor.shared.icon, size: 25), for: .normal)
|
|
|
- } else {
|
|
|
- header.buttonSwitch.setImage(UIImage.init(named: "switchGrid")?.image(color: NCBrandColor.shared.icon, size: 25), for: .normal)
|
|
|
- }
|
|
|
-
|
|
|
- header.delegate = self
|
|
|
- header.setStatusButton(count: dataSource.metadatas.count)
|
|
|
- header.setTitleSorted(datasourceTitleButton: titleButton)
|
|
|
- header.viewRichWorkspaceHeightConstraint.constant = headerRichWorkspaceHeight
|
|
|
- header.setRichWorkspaceText(richWorkspaceText: richWorkspaceText)
|
|
|
-
|
|
|
- return header
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
|
|
|
-
|
|
|
- let info = dataSource.getFilesInformation()
|
|
|
- footer.setTitleLabel(directories: info.directories, files: info.files, size: info.size)
|
|
|
-
|
|
|
- return footer
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
func numberOfSections(in collectionView: UICollectionView) -> Int {
|
|
|
return 1
|
|
|
}
|
|
@@ -445,11 +341,7 @@ extension NCShareExtension: UICollectionViewDataSource {
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
|
|
|
|
guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else {
|
|
|
- if 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 tableShare: tableShare?
|
|
@@ -465,265 +357,141 @@ extension NCShareExtension: UICollectionViewDataSource {
|
|
|
if dataSource.metadataShare[metadata.ocId] != nil {
|
|
|
tableShare = dataSource.metadataShare[metadata.ocId]
|
|
|
}
|
|
|
+
|
|
|
+ let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
|
|
|
+ cell.delegate = self
|
|
|
|
|
|
- // LAYOUT LIST
|
|
|
+ cell.objectId = metadata.ocId
|
|
|
+ cell.indexPath = indexPath
|
|
|
+ cell.labelTitle.text = metadata.fileNameView
|
|
|
+ cell.labelTitle.textColor = NCBrandColor.shared.textView
|
|
|
+ cell.separator.backgroundColor = NCBrandColor.shared.separator
|
|
|
|
|
|
- if layout == NCGlobal.shared.layoutList {
|
|
|
-
|
|
|
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
|
|
|
- cell.delegate = self
|
|
|
-
|
|
|
- cell.objectId = metadata.ocId
|
|
|
- cell.indexPath = indexPath
|
|
|
- cell.labelTitle.text = metadata.fileNameView
|
|
|
- cell.labelTitle.textColor = NCBrandColor.shared.textView
|
|
|
- cell.separator.backgroundColor = NCBrandColor.shared.separator
|
|
|
+ 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 {
|
|
|
|
|
|
- cell.imageSelect.image = nil
|
|
|
- cell.imageStatus.image = nil
|
|
|
- cell.imageLocal.image = nil
|
|
|
- cell.imageFavorite.image = nil
|
|
|
- cell.imageShared.image = nil
|
|
|
- cell.imageMore.image = nil
|
|
|
+ if metadata.e2eEncrypted {
|
|
|
+ cell.imageItem.image = NCBrandColor.cacheImages.folderEncrypted
|
|
|
+ } else if isShare {
|
|
|
+ cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe
|
|
|
+ } else if (tableShare != nil && tableShare?.shareType != 3) {
|
|
|
+ cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe
|
|
|
+ } else if (tableShare != nil && tableShare?.shareType == 3) {
|
|
|
+ cell.imageItem.image = NCBrandColor.cacheImages.folderPublic
|
|
|
+ } 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 = nil
|
|
|
- cell.imageItem.backgroundColor = nil
|
|
|
+ cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
|
|
|
|
|
|
- cell.progressView.progress = 0.0
|
|
|
+ let lockServerUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
|
|
|
+ let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", activeAccount.account, lockServerUrl))
|
|
|
|
|
|
- if metadata.directory {
|
|
|
-
|
|
|
- if metadata.e2eEncrypted {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderEncrypted
|
|
|
- } else if isShare {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe
|
|
|
- } else if (tableShare != nil && tableShare?.shareType != 3) {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe
|
|
|
- } else if (tableShare != nil && tableShare?.shareType == 3) {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderPublic
|
|
|
- } 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.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
|
|
|
-
|
|
|
- let lockServerUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
|
|
|
- let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", activeAccount.account, lockServerUrl))
|
|
|
-
|
|
|
- // Local image: offline
|
|
|
- if tableDirectory != nil && tableDirectory!.offline {
|
|
|
- cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
|
|
|
- cell.imageItem.image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
|
|
|
- } else {
|
|
|
- if metadata.hasPreview {
|
|
|
- cell.imageItem.backgroundColor = .lightGray
|
|
|
- } else {
|
|
|
- if metadata.iconName.count > 0 {
|
|
|
- cell.imageItem.image = UIImage.init(named: metadata.iconName)
|
|
|
- } else {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.file
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
|
|
|
-
|
|
|
- // image local
|
|
|
- if dataSource.metadataOffLine.contains(metadata.ocId) {
|
|
|
- cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
|
|
|
- } else if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
|
|
|
- cell.imageLocal.image = NCBrandColor.cacheImages.local
|
|
|
- }
|
|
|
+ // Local image: offline
|
|
|
+ if tableDirectory != nil && tableDirectory!.offline {
|
|
|
+ cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
|
|
|
}
|
|
|
|
|
|
- // image Favorite
|
|
|
- if metadata.favorite {
|
|
|
- cell.imageFavorite.image = NCBrandColor.cacheImages.favorite
|
|
|
- }
|
|
|
+ } else {
|
|
|
|
|
|
- // Share image
|
|
|
- if (isShare) {
|
|
|
- cell.imageShared.image = NCBrandColor.cacheImages.shared
|
|
|
- } else if (tableShare != nil && tableShare?.shareType == 3) {
|
|
|
- cell.imageShared.image = NCBrandColor.cacheImages.shareByLink
|
|
|
- } else if (tableShare != nil && tableShare?.shareType != 3) {
|
|
|
- cell.imageShared.image = NCBrandColor.cacheImages.shared
|
|
|
+ if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
|
|
|
+ cell.imageItem.image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
|
|
|
} else {
|
|
|
- cell.imageShared.image = NCBrandColor.cacheImages.canShare
|
|
|
- }
|
|
|
- if metadata.ownerId.count > 0 && metadata.ownerId != activeAccount.userId {
|
|
|
- let fileNameUser = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(activeAccount.user, urlBase: activeAccount.urlBase)) + "-" + metadata.ownerId + ".png"
|
|
|
- if FileManager.default.fileExists(atPath: fileNameUser) {
|
|
|
- cell.imageShared.image = UIImage(contentsOfFile: fileNameUser)
|
|
|
+ if metadata.hasPreview {
|
|
|
+ cell.imageItem.backgroundColor = .lightGray
|
|
|
} else {
|
|
|
- NCCommunication.shared.downloadAvatar(userId: metadata.ownerId, fileNameLocalPath: fileNameUser, size: NCGlobal.shared.avatarSize) { (account, data, errorCode, errorMessage) in
|
|
|
- if errorCode == 0 && account == self.activeAccount.account {
|
|
|
- cell.imageShared.image = UIImage(contentsOfFile: fileNameUser)
|
|
|
- }
|
|
|
+ if metadata.iconName.count > 0 {
|
|
|
+ cell.imageItem.image = UIImage.init(named: metadata.iconName)
|
|
|
+ } else {
|
|
|
+ cell.imageItem.image = NCBrandColor.cacheImages.file
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- 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) + " · " + CCUtility.transformedSize(metadata.size)
|
|
|
|
|
|
- // Remove last separator
|
|
|
- if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 {
|
|
|
- cell.separator.isHidden = true
|
|
|
- } else {
|
|
|
- cell.separator.isHidden = false
|
|
|
+ // image local
|
|
|
+ if dataSource.metadataOffLine.contains(metadata.ocId) {
|
|
|
+ cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
|
|
|
+ } else if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
|
|
|
+ cell.imageLocal.image = NCBrandColor.cacheImages.local
|
|
|
}
|
|
|
-
|
|
|
- return cell
|
|
|
}
|
|
|
|
|
|
- // LAYOUT GRID
|
|
|
+ // image Favorite
|
|
|
+ if metadata.favorite {
|
|
|
+ cell.imageFavorite.image = NCBrandColor.cacheImages.favorite
|
|
|
+ }
|
|
|
|
|
|
- if layout == NCGlobal.shared.layoutGrid {
|
|
|
-
|
|
|
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell
|
|
|
- cell.delegate = self
|
|
|
-
|
|
|
- cell.objectId = metadata.ocId
|
|
|
- cell.indexPath = indexPath
|
|
|
- cell.labelTitle.text = metadata.fileNameView
|
|
|
- cell.labelTitle.textColor = NCBrandColor.shared.textView
|
|
|
-
|
|
|
- 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 (tableShare != nil && tableShare!.shareType != 3) {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe
|
|
|
- } else if (tableShare != nil && tableShare!.shareType == 3) {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.folderPublic
|
|
|
- } 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
|
|
|
- }
|
|
|
-
|
|
|
- let lockServerUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
|
|
|
- let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", activeAccount.account, lockServerUrl))
|
|
|
-
|
|
|
- // Local image: offline
|
|
|
- if tableDirectory != nil && tableDirectory!.offline {
|
|
|
- cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
|
|
|
- }
|
|
|
-
|
|
|
+ // Share image
|
|
|
+ if (isShare) {
|
|
|
+ cell.imageShared.image = NCBrandColor.cacheImages.shared
|
|
|
+ } else if (tableShare != nil && tableShare?.shareType == 3) {
|
|
|
+ cell.imageShared.image = NCBrandColor.cacheImages.shareByLink
|
|
|
+ } else if (tableShare != nil && tableShare?.shareType != 3) {
|
|
|
+ cell.imageShared.image = NCBrandColor.cacheImages.shared
|
|
|
+ } else {
|
|
|
+ cell.imageShared.image = NCBrandColor.cacheImages.canShare
|
|
|
+ }
|
|
|
+ if metadata.ownerId.count > 0 && metadata.ownerId != activeAccount.userId {
|
|
|
+ let fileNameUser = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(activeAccount.user, urlBase: activeAccount.urlBase)) + "-" + metadata.ownerId + ".png"
|
|
|
+ if FileManager.default.fileExists(atPath: fileNameUser) {
|
|
|
+ cell.imageShared.image = UIImage(contentsOfFile: fileNameUser)
|
|
|
} else {
|
|
|
-
|
|
|
- if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
|
|
|
- cell.imageItem.image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
|
|
|
- } else {
|
|
|
- if metadata.hasPreview {
|
|
|
- cell.imageItem.backgroundColor = .lightGray
|
|
|
- } else {
|
|
|
- if metadata.iconName.count > 0 {
|
|
|
- cell.imageItem.image = UIImage.init(named: metadata.iconName)
|
|
|
- } else {
|
|
|
- cell.imageItem.image = NCBrandColor.cacheImages.file
|
|
|
- }
|
|
|
+ NCCommunication.shared.downloadAvatar(userId: metadata.ownerId, fileNameLocalPath: fileNameUser, size: NCGlobal.shared.avatarSize) { (account, data, errorCode, errorMessage) in
|
|
|
+ if errorCode == 0 && account == self.activeAccount.account {
|
|
|
+ cell.imageShared.image = UIImage(contentsOfFile: fileNameUser)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // image Local
|
|
|
- if dataSource.metadataOffLine.contains(metadata.ocId) {
|
|
|
- cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
|
|
|
- } else if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
|
|
|
- cell.imageLocal.image = NCBrandColor.cacheImages.local
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // image Favorite
|
|
|
- if metadata.favorite {
|
|
|
- cell.imageFavorite.image = NCBrandColor.cacheImages.favorite
|
|
|
- }
|
|
|
-
|
|
|
- cell.imageSelect.isHidden = true
|
|
|
- cell.backgroundView = nil
|
|
|
- cell.hideButtonMore(true)
|
|
|
-
|
|
|
- // Live Photo
|
|
|
- if metadata.livePhoto {
|
|
|
- cell.imageStatus.image = NCBrandColor.cacheImages.livePhoto
|
|
|
}
|
|
|
-
|
|
|
- return cell
|
|
|
}
|
|
|
|
|
|
- return collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell
|
|
|
- }
|
|
|
-}
|
|
|
+ cell.imageSelect.isHidden = true
|
|
|
+ cell.backgroundView = nil
|
|
|
+ cell.hideButtonMore(true)
|
|
|
+ cell.hideButtonShare(true)
|
|
|
+ cell.selectMode(false)
|
|
|
|
|
|
-extension NCShareExtension: UICollectionViewDelegateFlowLayout {
|
|
|
-
|
|
|
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
|
|
|
-
|
|
|
- headerRichWorkspaceHeight = 0
|
|
|
+ // Live Photo
|
|
|
+ if metadata.livePhoto {
|
|
|
+ cell.imageStatus.image = NCBrandColor.cacheImages.livePhoto
|
|
|
+ }
|
|
|
|
|
|
- /*
|
|
|
- if let richWorkspaceText = richWorkspaceText {
|
|
|
- let trimmed = richWorkspaceText.trimmingCharacters(in: .whitespaces)
|
|
|
- if trimmed.count > 0 {
|
|
|
- headerRichWorkspaceHeight = UIScreen.main.bounds.size.height / 4
|
|
|
- }
|
|
|
+ // Remove last separator
|
|
|
+ if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 {
|
|
|
+ cell.separator.isHidden = true
|
|
|
+ } else {
|
|
|
+ cell.separator.isHidden = false
|
|
|
}
|
|
|
- */
|
|
|
|
|
|
- return CGSize(width: collectionView.frame.width, height: headerHeight + headerRichWorkspaceHeight)
|
|
|
- }
|
|
|
-
|
|
|
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
|
|
|
- return CGSize(width: collectionView.frame.width, height: footerHeight)
|
|
|
+ return cell
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
extension NCShareExtension: UITableViewDelegate {
|
|
|
|
|
|
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
|
- return heightCell
|
|
|
+ return 50
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -756,13 +524,9 @@ extension NCShareExtension: UITableViewDataSource {
|
|
|
|
|
|
extension NCShareExtension {
|
|
|
|
|
|
- @objc func reloadDataSource() {
|
|
|
- loadDatasource(withLoadFolder: false)
|
|
|
- }
|
|
|
-
|
|
|
- @objc func loadDatasource(withLoadFolder: Bool) {
|
|
|
+ @objc func reloadDatasource(withLoadFolder: Bool) {
|
|
|
|
|
|
- self.navigationItem.title = titleCurrentFolder
|
|
|
+ setNavigationBar()
|
|
|
|
|
|
(layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: keyLayout, serverUrl: serverUrl)
|
|
|
|
|
@@ -775,9 +539,6 @@ extension NCShareExtension {
|
|
|
self.refreshControl.endRefreshing()
|
|
|
}
|
|
|
|
|
|
- let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", activeAccount.account,serverUrl))
|
|
|
- richWorkspaceText = directory?.richWorkspace
|
|
|
-
|
|
|
collectionView.reloadData()
|
|
|
}
|
|
|
|
|
@@ -786,7 +547,7 @@ extension NCShareExtension {
|
|
|
NCNetworking.shared.createFolder(fileName: fileName, serverUrl: serverUrl, account: activeAccount.account, urlBase: activeAccount.urlBase) { (errorCode, errorDescription) in
|
|
|
|
|
|
if errorCode == 0 {
|
|
|
- self.loadDatasource(withLoadFolder: true)
|
|
|
+ self.reloadDatasource(withLoadFolder: true)
|
|
|
} else {
|
|
|
NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
|
|
|
}
|
|
@@ -803,7 +564,7 @@ extension NCShareExtension {
|
|
|
NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
|
|
|
}
|
|
|
self.networkInProgress = false
|
|
|
- self.loadDatasource(withLoadFolder: false)
|
|
|
+ self.reloadDatasource(withLoadFolder: false)
|
|
|
}
|
|
|
}
|
|
|
|