NCCollectionCommon.swift 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. //
  2. // NCCollectionCommon.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 08/09/2020.
  6. // Copyright © 2020 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import Foundation
  24. import NCCommunication
  25. class NCCollectionCommon: NSObject {
  26. @objc static let shared: NCCollectionCommon = {
  27. let instance = NCCollectionCommon()
  28. instance.createImagesThemingColor()
  29. return instance
  30. }()
  31. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  32. struct NCCollectionCommonImages {
  33. static var cellSharedImage = UIImage()
  34. static var cellCanShareImage = UIImage()
  35. static var cellShareByLinkImage = UIImage()
  36. static var cellFavouriteImage = UIImage()
  37. static var cellMoreImage = UIImage()
  38. static var cellCommentImage = UIImage()
  39. static var cellLivePhotoImage = UIImage()
  40. static var cellFolderEncryptedImage = UIImage()
  41. static var cellFolderSharedWithMeImage = UIImage()
  42. static var cellFolderPublicImage = UIImage()
  43. static var cellFolderGroupImage = UIImage()
  44. static var cellFolderExternalImage = UIImage()
  45. static var cellFolderAutomaticUploadImage = UIImage()
  46. static var cellFolderImage = UIImage()
  47. static var cellPlayImage = UIImage()
  48. }
  49. // MARK: -
  50. @objc func createImagesThemingColor() {
  51. NCCollectionCommonImages.cellSharedImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), width: 100, height: 100, color: NCBrandColor.sharedInstance.textView)
  52. NCCollectionCommonImages.cellCanShareImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), width: 100, height: 100, color: NCBrandColor.sharedInstance.optionItem)
  53. NCCollectionCommonImages.cellShareByLinkImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "sharebylink"), width: 100, height: 100, color: NCBrandColor.sharedInstance.optionItem)
  54. NCCollectionCommonImages.cellFavouriteImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "favorite"), width: 100, height: 100, color: NCBrandColor.sharedInstance.yellowFavorite)
  55. NCCollectionCommonImages.cellMoreImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "more"), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
  56. NCCollectionCommonImages.cellCommentImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "comment"), width: 30, height: 30, color: NCBrandColor.sharedInstance.graySoft)
  57. NCCollectionCommonImages.cellLivePhotoImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "livePhoto"), width: 100, height: 100, color: NCBrandColor.sharedInstance.textView)
  58. NCCollectionCommonImages.cellFolderEncryptedImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folderEncrypted"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
  59. NCCollectionCommonImages.cellFolderSharedWithMeImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder_shared_with_me"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
  60. NCCollectionCommonImages.cellFolderPublicImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder_public"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
  61. NCCollectionCommonImages.cellFolderGroupImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder_group"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
  62. NCCollectionCommonImages.cellFolderExternalImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder_external"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
  63. NCCollectionCommonImages.cellFolderAutomaticUploadImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folderAutomaticUpload"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
  64. NCCollectionCommonImages.cellFolderImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 600, height: 600, color: NCBrandColor.sharedInstance.brandElement)
  65. NCCollectionCommonImages.cellPlayImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "play"), width: 100, height: 100, color: .white)
  66. }
  67. // MARK: -
  68. @objc func createFolder() {
  69. guard let serverUrl = appDelegate.activeServerUrl else { return }
  70. let alertController = UIAlertController(title: NSLocalizedString("_create_folder_on_", comment: ""), message: nil, preferredStyle: .alert)
  71. alertController.addTextField { (textField) in
  72. textField.autocapitalizationType = UITextAutocapitalizationType.sentences
  73. textField.delegate = self as? UITextFieldDelegate
  74. }
  75. let cancelAction = UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel, handler: nil)
  76. let okAction = UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in
  77. if let fileNameFolder = alertController.textFields?.first?.text {
  78. NCNetworking.shared.createFolder(fileName: fileNameFolder, serverUrl: serverUrl, account: self.appDelegate.account, urlBase: self.appDelegate.urlBase, overwrite: false) { (errorCode, errorDescription) in
  79. if errorCode != 0 {
  80. NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
  81. }
  82. }
  83. }
  84. })
  85. okAction.isEnabled = false
  86. alertController.addAction(cancelAction)
  87. alertController.addAction(okAction)
  88. appDelegate.window.rootViewController?.present(alertController, animated: true, completion: nil)
  89. }
  90. // MARK: -
  91. func cellForItemAt(indexPath: IndexPath, collectionView: UICollectionView, cell: UICollectionViewCell, metadata: tableMetadata, metadataFolder: tableMetadata?, serverUrl: String, isEditMode: Bool, selectocId: [String], autoUploadFileName: String, autoUploadDirectory: String, hideButtonMore: Bool, downloadThumbnail: Bool, shares: [tableShare]?, source: UIViewController, dataSource: NCDataSource?) {
  92. var tableShare: tableShare?
  93. // Share
  94. if shares != nil {
  95. for share in shares! {
  96. if share.fileName == metadata.fileName {
  97. tableShare = share
  98. break
  99. }
  100. }
  101. }
  102. // Download preview
  103. if downloadThumbnail {
  104. NCOperationQueue.shared.downloadThumbnail(metadata: metadata, urlBase: appDelegate.urlBase, view: collectionView, indexPath: indexPath)
  105. }
  106. var isShare = false
  107. var isMounted = false
  108. if metadataFolder != nil {
  109. isShare = metadata.permissions.contains(k_permission_shared) && !metadataFolder!.permissions.contains(k_permission_shared)
  110. isMounted = metadata.permissions.contains(k_permission_mounted) && !metadataFolder!.permissions.contains(k_permission_mounted)
  111. }
  112. if cell is NCListCell {
  113. let cell = cell as! NCListCell
  114. cell.delegate = source as? NCListCellDelegate
  115. cell.objectId = metadata.ocId
  116. cell.indexPath = indexPath
  117. cell.labelTitle.text = metadata.fileNameView
  118. cell.labelTitle.textColor = NCBrandColor.sharedInstance.textView
  119. cell.imageStatus.image = nil
  120. cell.imageLocal.image = nil
  121. cell.imageFavorite.image = nil
  122. cell.imageShared.image = nil
  123. cell.imageItem.image = nil
  124. cell.imageItem.backgroundColor = nil
  125. if metadata.directory {
  126. if metadata.e2eEncrypted {
  127. cell.imageItem.image = NCCollectionCommonImages.cellFolderEncryptedImage
  128. } else if isShare {
  129. cell.imageItem.image = NCCollectionCommonImages.cellFolderSharedWithMeImage
  130. } else if (tableShare != nil && tableShare!.shareType != 3) {
  131. cell.imageItem.image = NCCollectionCommonImages.cellFolderSharedWithMeImage
  132. } else if (tableShare != nil && tableShare!.shareType == 3) {
  133. cell.imageItem.image = NCCollectionCommonImages.cellFolderPublicImage
  134. } else if metadata.mountType == "group" {
  135. cell.imageItem.image = NCCollectionCommonImages.cellFolderGroupImage
  136. } else if isMounted {
  137. cell.imageItem.image = NCCollectionCommonImages.cellFolderExternalImage
  138. } else if metadata.fileName == autoUploadFileName && serverUrl == autoUploadDirectory {
  139. cell.imageItem.image = NCCollectionCommonImages.cellFolderAutomaticUploadImage
  140. } else {
  141. cell.imageItem.image = NCCollectionCommonImages.cellFolderImage
  142. }
  143. cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
  144. let lockServerUrl = CCUtility.stringAppendServerUrl(serverUrl, addFileName: metadata.fileName)!
  145. let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, lockServerUrl))
  146. // Local image: offline
  147. if tableDirectory != nil && tableDirectory!.offline {
  148. cell.imageLocal.image = UIImage.init(named: "offlineFlag")
  149. }
  150. } else {
  151. if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
  152. cell.imageItem.image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
  153. } else {
  154. if metadata.hasPreview {
  155. cell.imageItem.backgroundColor = .lightGray
  156. } else {
  157. if metadata.iconName.count > 0 {
  158. cell.imageItem.image = UIImage.init(named: metadata.iconName)
  159. } else {
  160. cell.imageItem.image = UIImage.init(named: "file")
  161. }
  162. }
  163. }
  164. cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
  165. // image local
  166. let size = CCUtility.fileProviderStorageSize(metadata.ocId, fileNameView: metadata.fileNameView)
  167. if size > 0 {
  168. let tableLocalFile = NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
  169. if tableLocalFile == nil && size == metadata.size {
  170. NCManageDatabase.sharedInstance.addLocalFile(metadata: metadata)
  171. }
  172. if tableLocalFile?.offline ?? false {
  173. cell.imageLocal.image = UIImage.init(named: "offlineFlag")
  174. } else{
  175. cell.imageLocal.image = UIImage.init(named: "local")
  176. }
  177. }
  178. }
  179. // image Favorite
  180. if metadata.favorite {
  181. cell.imageFavorite.image = NCCollectionCommonImages.cellFavouriteImage
  182. }
  183. // Share image
  184. if (isShare) {
  185. cell.imageShared.image = NCCollectionCommonImages.cellSharedImage
  186. } else if (tableShare != nil && tableShare!.shareType == 3) {
  187. cell.imageShared.image = NCCollectionCommonImages.cellShareByLinkImage
  188. } else if (tableShare != nil && tableShare!.shareType != 3) {
  189. cell.imageShared.image = NCCollectionCommonImages.cellSharedImage
  190. } else {
  191. cell.imageShared.image = NCCollectionCommonImages.cellCanShareImage
  192. }
  193. if metadata.ownerId.count > 0 && metadata.ownerId != appDelegate.userID {
  194. // Load avatar
  195. let fileNameSource = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase) + "-" + metadata.ownerId + ".png"
  196. let fileNameSourceAvatar = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase) + "-avatar-" + metadata.ownerId + ".png"
  197. if FileManager.default.fileExists(atPath: fileNameSourceAvatar) {
  198. cell.imageShared.image = UIImage(contentsOfFile: fileNameSourceAvatar)
  199. } else if FileManager.default.fileExists(atPath: fileNameSource) {
  200. cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar)
  201. } else {
  202. NCCommunication.shared.downloadAvatar(userID: metadata.ownerId, fileNameLocalPath: fileNameSource, size: Int(k_avatar_size)) { (account, data, errorCode, errorMessage) in
  203. if errorCode == 0 && account == self.appDelegate.account {
  204. cell.imageShared.image = NCUtility.shared.createAvatar(fileNameSource: fileNameSource, fileNameSourceAvatar: fileNameSourceAvatar)
  205. }
  206. }
  207. }
  208. }
  209. if isEditMode {
  210. cell.imageItemLeftConstraint.constant = 45
  211. cell.imageSelect.isHidden = false
  212. if selectocId.contains(metadata.ocId) {
  213. cell.imageSelect.image = CCGraphics.scale(UIImage.init(named: "checkedYes"), to: CGSize(width: 50, height: 50), isAspectRation: true)
  214. cell.backgroundView = NCUtility.shared.cellBlurEffect(with: cell.bounds)
  215. } else {
  216. cell.imageSelect.image = CCGraphics.scale(UIImage.init(named: "checkedNo"), to: CGSize(width: 50, height: 50), isAspectRation: true)
  217. cell.backgroundView = nil
  218. }
  219. } else {
  220. cell.imageItemLeftConstraint.constant = 10
  221. cell.imageSelect.isHidden = true
  222. cell.backgroundView = nil
  223. }
  224. // Transfer
  225. if metadata.status == k_metadataStatusInDownload || metadata.status == k_metadataStatusDownloading || metadata.status >= k_metadataStatusTypeUpload {
  226. cell.progressView.isHidden = false
  227. cell.setButtonMore(named: "stop")
  228. } else {
  229. cell.progressView.isHidden = true
  230. cell.progressView.progress = 0.0
  231. cell.setButtonMore(named: "more")
  232. }
  233. // Remove last separator
  234. if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 {
  235. cell.separator.isHidden = true
  236. } else {
  237. cell.separator.isHidden = false
  238. }
  239. } else if cell is NCGridCell {
  240. let cell = cell as! NCGridCell
  241. cell.delegate = source as? NCGridCellDelegate
  242. cell.objectId = metadata.ocId
  243. cell.indexPath = indexPath
  244. cell.labelTitle.text = metadata.fileNameView
  245. cell.labelTitle.textColor = NCBrandColor.sharedInstance.textView
  246. cell.imageStatus.image = nil
  247. cell.imageLocal.image = nil
  248. cell.imageFavorite.image = nil
  249. cell.imageItem.image = nil
  250. cell.imageItem.backgroundColor = nil
  251. if metadata.directory {
  252. if metadata.e2eEncrypted {
  253. cell.imageItem.image = NCCollectionCommonImages.cellFolderEncryptedImage
  254. } else if isShare {
  255. cell.imageItem.image = NCCollectionCommonImages.cellFolderSharedWithMeImage
  256. } else if (tableShare != nil && tableShare!.shareType != 3) {
  257. cell.imageItem.image = NCCollectionCommonImages.cellFolderSharedWithMeImage
  258. } else if (tableShare != nil && tableShare!.shareType == 3) {
  259. cell.imageItem.image = NCCollectionCommonImages.cellFolderPublicImage
  260. } else if metadata.mountType == "group" {
  261. cell.imageItem.image = NCCollectionCommonImages.cellFolderGroupImage
  262. } else if isMounted {
  263. cell.imageItem.image = NCCollectionCommonImages.cellFolderExternalImage
  264. } else if metadata.fileName == autoUploadFileName && serverUrl == autoUploadDirectory {
  265. cell.imageItem.image = NCCollectionCommonImages.cellFolderAutomaticUploadImage
  266. } else {
  267. cell.imageItem.image = NCCollectionCommonImages.cellFolderImage
  268. }
  269. let lockServerUrl = CCUtility.stringAppendServerUrl(serverUrl, addFileName: metadata.fileName)!
  270. let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, lockServerUrl))
  271. // Local image: offline
  272. if tableDirectory != nil && tableDirectory!.offline {
  273. cell.imageLocal.image = UIImage.init(named: "offlineFlag")
  274. }
  275. } else {
  276. if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
  277. cell.imageItem.image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
  278. } else {
  279. if metadata.hasPreview {
  280. cell.imageItem.backgroundColor = .lightGray
  281. } else {
  282. if metadata.iconName.count > 0 {
  283. cell.imageItem.image = UIImage.init(named: metadata.iconName)
  284. } else {
  285. cell.imageItem.image = UIImage.init(named: "file")
  286. }
  287. }
  288. }
  289. // image Local
  290. let tableLocalFile = NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
  291. if tableLocalFile != nil && CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
  292. if tableLocalFile!.offline { cell.imageLocal.image = UIImage.init(named: "offlineFlag") }
  293. else { cell.imageLocal.image = UIImage.init(named: "local") }
  294. }
  295. }
  296. // image Favorite
  297. if metadata.favorite {
  298. cell.imageFavorite.image = NCCollectionCommonImages.cellFavouriteImage
  299. }
  300. if isEditMode {
  301. cell.imageSelect.isHidden = false
  302. if selectocId.contains(metadata.ocId) {
  303. cell.imageSelect.image = CCGraphics.scale(UIImage.init(named: "checkedYes"), to: CGSize(width: 50, height: 50), isAspectRation: true)
  304. cell.backgroundView = NCUtility.shared.cellBlurEffect(with: cell.bounds)
  305. } else {
  306. cell.imageSelect.isHidden = true
  307. cell.backgroundView = nil
  308. }
  309. } else {
  310. cell.imageSelect.isHidden = true
  311. cell.backgroundView = nil
  312. }
  313. // Transfer
  314. if metadata.status == k_metadataStatusInDownload || metadata.status == k_metadataStatusDownloading || metadata.status >= k_metadataStatusTypeUpload {
  315. cell.progressView.isHidden = false
  316. cell.setButtonMore(named: "stop")
  317. } else {
  318. cell.progressView.isHidden = true
  319. cell.progressView.progress = 0.0
  320. cell.setButtonMore(named: "more")
  321. }
  322. }
  323. }
  324. }
  325. // MARK: - List Layout
  326. class NCListLayout: UICollectionViewFlowLayout {
  327. let itemHeight: CGFloat = 60
  328. override init() {
  329. super.init()
  330. sectionHeadersPinToVisibleBounds = false
  331. minimumInteritemSpacing = 0
  332. minimumLineSpacing = 1
  333. self.scrollDirection = .vertical
  334. self.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
  335. }
  336. required init?(coder aDecoder: NSCoder) {
  337. fatalError("init(coder:) has not been implemented")
  338. }
  339. override var itemSize: CGSize {
  340. get {
  341. if let collectionView = collectionView {
  342. let itemWidth: CGFloat = collectionView.frame.width
  343. return CGSize(width: itemWidth, height: self.itemHeight)
  344. }
  345. // Default fallback
  346. return CGSize(width: 100, height: 100)
  347. }
  348. set {
  349. super.itemSize = newValue
  350. }
  351. }
  352. override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint) -> CGPoint {
  353. return proposedContentOffset
  354. }
  355. }
  356. // MARK: - Grid Layout
  357. class NCGridLayout: UICollectionViewFlowLayout {
  358. var heightLabelPlusButton: CGFloat = 45
  359. var marginLeftRight: CGFloat = 6
  360. var itemForLine: CGFloat = 3
  361. override init() {
  362. super.init()
  363. sectionHeadersPinToVisibleBounds = false
  364. minimumInteritemSpacing = 1
  365. minimumLineSpacing = marginLeftRight
  366. self.scrollDirection = .vertical
  367. self.sectionInset = UIEdgeInsets(top: 10, left: marginLeftRight, bottom: 0, right: marginLeftRight)
  368. }
  369. required init?(coder aDecoder: NSCoder) {
  370. fatalError("init(coder:) has not been implemented")
  371. }
  372. override var itemSize: CGSize {
  373. get {
  374. if let collectionView = collectionView {
  375. let itemWidth: CGFloat = (collectionView.frame.width - marginLeftRight * 2 - marginLeftRight * (itemForLine - 1)) / itemForLine
  376. let itemHeight: CGFloat = itemWidth + heightLabelPlusButton
  377. return CGSize(width: itemWidth, height: itemHeight)
  378. }
  379. // Default fallback
  380. return CGSize(width: 100, height: 100)
  381. }
  382. set {
  383. super.itemSize = newValue
  384. }
  385. }
  386. override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint) -> CGPoint {
  387. return proposedContentOffset
  388. }
  389. }
  390. // MARK: - NCSelect + Delegate
  391. extension NCCollectionCommon: NCSelectDelegate {
  392. func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, array: [Any], buttonType: String, overwrite: Bool) {
  393. if (serverUrl != nil && array.count > 0) {
  394. var move = true
  395. if buttonType == "done1" { move = false }
  396. for metadata in array as! [tableMetadata] {
  397. NCOperationQueue.shared.copyMove(metadata: metadata, serverUrl: serverUrl!, overwrite: overwrite, move: move)
  398. }
  399. }
  400. }
  401. func openSelectView(viewController: UIViewController, array: [Any]) {
  402. let navigationController = UIStoryboard.init(name: "NCSelect", bundle: nil).instantiateInitialViewController() as! UINavigationController
  403. let vc = navigationController.topViewController as! NCSelect
  404. vc.delegate = self
  405. vc.hideButtonCreateFolder = false
  406. vc.selectFile = false
  407. vc.includeDirectoryE2EEncryption = false
  408. vc.includeImages = false
  409. vc.type = ""
  410. vc.titleButtonDone = NSLocalizedString("_move_", comment: "")
  411. vc.titleButtonDone1 = NSLocalizedString("_copy_",comment: "")
  412. vc.isButtonDone1Hide = false
  413. vc.isOverwriteHide = false
  414. vc.keyLayout = k_layout_view_move
  415. vc.array = array
  416. navigationController.modalPresentationStyle = .fullScreen
  417. viewController.present(navigationController, animated: true, completion: nil)
  418. }
  419. }