123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import UIKit
- class NCShareQuickStatusMenu: NSObject {
-
- func toggleMenu(viewController: UIViewController, directory: Bool, tableShare: tableShare) {
-
- print(tableShare.permissions)
- let menuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateInitialViewController() as! NCMenu
- var actions = [NCMenuAction]()
-
-
-
- actions.append(
- NCMenuAction(
- title: NSLocalizedString("_share_read_only_", comment: ""),
- icon: UIImage(),
- selected: tableShare.permissions == (NCGlobal.shared.permissionReadShare + NCGlobal.shared.permissionShareShare) || tableShare.permissions == NCGlobal.shared.permissionReadShare,
- on: false,
- action: { menuAction in
- let canShare = CCUtility.isPermission(toCanShare: tableShare.permissions)
- let permissions = CCUtility.getPermissionsValue(byCanEdit: false, andCanCreate: false, andCanChange: false, andCanDelete: false, andCanShare: canShare, andIsFolder: directory)
- NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterShareChangePermissions, userInfo: ["idShare": tableShare.idShare, "permissions": permissions, "hideDownload": tableShare.hideDownload])
- }
- )
- )
- actions.append(
- NCMenuAction(
- title: directory ? NSLocalizedString("_share_allow_upload_", comment: "") : NSLocalizedString("_share_editing_", comment: ""),
- icon: UIImage(),
- selected: tableShare.permissions == NCGlobal.shared.permissionMaxFileShare || tableShare.permissions == NCGlobal.shared.permissionMaxFolderShare || tableShare.permissions == NCGlobal.shared.permissionDefaultFileRemoteShareNoSupportShareOption,
- on: false,
- action: { menuAction in
- let canShare = CCUtility.isPermission(toCanShare: tableShare.permissions)
- let permissions = CCUtility.getPermissionsValue(byCanEdit: true, andCanCreate: true, andCanChange: true, andCanDelete: true, andCanShare: canShare, andIsFolder: directory)
- NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterShareChangePermissions, userInfo: ["idShare": tableShare.idShare, "permissions": permissions, "hideDownload": tableShare.hideDownload])
- }
- )
- )
-
-
-
- menuViewController.actions = actions
- let menuPanelController = NCMenuPanelController()
- menuPanelController.parentPresenter = viewController
- menuPanelController.delegate = menuViewController
- menuPanelController.set(contentViewController: menuViewController)
- menuPanelController.track(scrollView: menuViewController.tableView)
- viewController.present(menuPanelController, animated: true, completion: nil)
- }
- }
|