123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- import UIKit
- import FloatingPanel
- import NCCommunication
- extension NCMedia {
- func tapSelect() {
- self.isEditMode = false
- self.selectOcId.removeAll()
- self.reloadDataThenPerform { }
- }
- func toggleMenu() {
- var actions: [NCMenuAction] = []
- defer { presentMenu(with: actions) }
- if !isEditMode {
- if metadatas.count > 0 {
- actions.append(
- NCMenuAction(
- title: NSLocalizedString("_select_", comment: ""),
- icon: NCUtility.shared.loadImage(named: "checkmark.circle.fill"),
- action: { _ in
- self.isEditMode = true
- }
- )
- )
- }
- actions.append(
- NCMenuAction(
- title: NSLocalizedString(filterClassTypeImage ? "_media_viewimage_show_" : "_media_viewimage_hide_", comment: ""),
- icon: NCUtility.shared.loadImage(named: "photo"),
- selected: filterClassTypeImage,
- on: true,
- action: { _ in
- self.filterClassTypeImage = !self.filterClassTypeImage
- self.filterClassTypeVideo = false
- self.reloadDataSourceWithCompletion { _ in }
- }
- )
- )
- actions.append(
- NCMenuAction(
- title: NSLocalizedString(filterClassTypeVideo ? "_media_viewvideo_show_" : "_media_viewvideo_hide_", comment: ""),
- icon: NCUtility.shared.loadImage(named: "video"),
- selected: filterClassTypeVideo,
- on: true,
- action: { _ in
- self.filterClassTypeVideo = !self.filterClassTypeVideo
- self.filterClassTypeImage = false
- self.reloadDataSourceWithCompletion { _ in }
- }
- )
- )
- actions.append(
- NCMenuAction(
- title: NSLocalizedString("_select_media_folder_", comment: ""),
- icon: NCUtility.shared.loadImage(named: "folder"),
- action: { _ in
- let navigationController = UIStoryboard(name: "NCSelect", bundle: nil).instantiateInitialViewController() as! UINavigationController
- let viewController = navigationController.topViewController as! NCSelect
- viewController.delegate = self
- viewController.typeOfCommandView = .select
- viewController.type = "mediaFolder"
- self.present(navigationController, animated: true, completion: nil)
- }
- )
- )
- actions.append(
- NCMenuAction(
- title: NSLocalizedString("_media_by_modified_date_", comment: ""),
- icon: NCUtility.shared.loadImage(named: "circle.grid.cross.up.fill"),
- selected: CCUtility.getMediaSortDate() == "date",
- on: true,
- action: { _ in
- CCUtility.setMediaSortDate("date")
- self.reloadDataSourceWithCompletion { _ in }
- }
- )
- )
- actions.append(
- NCMenuAction(
- title: NSLocalizedString("_media_by_created_date_", comment: ""),
- icon: NCUtility.shared.loadImage(named: "circle.grid.cross.down.fill"),
- selected: CCUtility.getMediaSortDate() == "creationDate",
- on: true,
- action: { _ in
- CCUtility.setMediaSortDate("creationDate")
- self.reloadDataSourceWithCompletion { _ in }
- }
- )
- )
- actions.append(
- NCMenuAction(
- title: NSLocalizedString("_media_by_upload_date_", comment: ""),
- icon: NCUtility.shared.loadImage(named: "circle.grid.cross.right.fill"),
- selected: CCUtility.getMediaSortDate() == "uploadDate",
- on: true,
- action: { _ in
- CCUtility.setMediaSortDate("uploadDate")
- self.reloadDataSourceWithCompletion { _ in }
- }
- )
- )
- } else {
-
-
-
- actions.append(
- NCMenuAction(
- title: NSLocalizedString("_cancel_", comment: ""),
- icon: NCUtility.shared.loadImage(named: "xmark"),
- action: { _ in self.tapSelect() }
- )
- )
- guard !selectOcId.isEmpty else { return }
- let selectedMetadatas = selectOcId.compactMap(NCManageDatabase.shared.getMetadataFromOcId)
-
-
-
- actions.append(.openInAction(selectedMetadatas: selectedMetadatas, viewController: self, completion: tapSelect))
-
-
-
- actions.append(.saveMediaAction(selectedMediaMetadatas: selectedMetadatas, completion: tapSelect))
-
-
-
- actions.append(.moveOrCopyAction(selectedMetadatas: selectedMetadatas, completion: tapSelect))
-
-
-
- actions.append(.copyAction(selectOcId: selectOcId, hudView: self.view, completion: tapSelect))
-
-
-
- if !selectedMetadatas.contains(where: { $0.lock && $0.lockOwner != appDelegate.userId }) {
- actions.append(.deleteAction(selectedMetadatas: selectedMetadatas, metadataFolder: nil, viewController: self, completion: tapSelect))
- }
- }
- }
- }
|