|
@@ -22,6 +22,7 @@
|
|
|
//
|
|
|
|
|
|
import Foundation
|
|
|
+import NCCommunication
|
|
|
|
|
|
class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate {
|
|
|
|
|
@@ -717,7 +718,77 @@ extension NCCollectionViewCommon: UIViewControllerPreviewingDelegate {
|
|
|
|
|
|
extension NCCollectionViewCommon: UICollectionViewDelegate {
|
|
|
|
|
|
- func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { }
|
|
|
+ func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
|
+
|
|
|
+ guard let metadata = dataSource?.cellForItemAt(indexPath: indexPath) else { return }
|
|
|
+ metadataPush = metadata
|
|
|
+
|
|
|
+ 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 {
|
|
|
+
|
|
|
+ guard let serverUrlPush = CCUtility.stringAppendServerUrl(metadataPush!.serverUrl, addFileName: metadataPush!.fileName) else { return }
|
|
|
+
|
|
|
+ if layoutKey == k_layout_view_favorite {
|
|
|
+
|
|
|
+ let ncFavorite:NCFavorite = UIStoryboard(name: "NCFavorite", bundle: nil).instantiateInitialViewController() as! NCFavorite
|
|
|
+
|
|
|
+ ncFavorite.serverUrl = serverUrlPush
|
|
|
+ ncFavorite.titleCurrentFolder = metadataPush!.fileNameView
|
|
|
+
|
|
|
+ self.navigationController?.pushViewController(ncFavorite, animated: true)
|
|
|
+ }
|
|
|
+
|
|
|
+ if layoutKey == k_layout_view_offline {
|
|
|
+
|
|
|
+ let ncOffline:NCOffline = UIStoryboard(name: "NCOffline", bundle: nil).instantiateInitialViewController() as! NCOffline
|
|
|
+
|
|
|
+ ncOffline.serverUrl = serverUrlPush
|
|
|
+ ncOffline.titleCurrentFolder = metadataPush!.fileNameView
|
|
|
+
|
|
|
+ self.navigationController?.pushViewController(ncOffline, animated: true)
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if metadataFolder?.e2eEncrypted ?? false && !CCUtility.isEnd(toEndEnabled: appDelegate.account) {
|
|
|
+ NCContentPresenter.shared.messageNotification("_info_", description: "_e2e_goto_settings_for_enable_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: Int(k_CCErrorE2EENotEnabled), forced: true)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if metadata.typeFile == k_metadataTypeFile_document && NCUtility.shared.isDirectEditing(account: metadata.account, contentType: metadata.contentType) != nil {
|
|
|
+ if NCCommunication.shared.isNetworkReachable() {
|
|
|
+ performSegue(withIdentifier: "segueDetail", sender: self)
|
|
|
+ } else {
|
|
|
+ NCContentPresenter.shared.messageNotification("_info_", description: "_go_online_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: Int(k_CCErrorOffline), forced: true)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if metadata.typeFile == k_metadataTypeFile_document && NCUtility.shared.isRichDocument(metadata) {
|
|
|
+ if NCCommunication.shared.isNetworkReachable() {
|
|
|
+ performSegue(withIdentifier: "segueDetail", sender: self)
|
|
|
+ } else {
|
|
|
+ NCContentPresenter.shared.messageNotification("_info_", description: "_go_online_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: Int(k_CCErrorOffline), forced: true)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if CCUtility.fileProviderStorageExists(metadataPush?.ocId, fileNameView: metadataPush?.fileNameView) {
|
|
|
+ performSegue(withIdentifier: "segueDetail", sender: self)
|
|
|
+ } else {
|
|
|
+ NCNetworking.shared.download(metadata: metadataPush!, selector: selectorLoadFileView) { (_) in }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
func collectionViewSelectAll() {
|
|
|
selectOcId.removeAll()
|