NCShare.swift 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. //
  2. // NCShare.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 17/07/2019.
  6. // Copyright © 2019 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 Parchment
  25. import DropDown
  26. import NCCommunication
  27. class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDelegate, NCShareUserCellDelegate, NCShareNetworkingDelegate {
  28. @IBOutlet weak var viewContainerConstraint: NSLayoutConstraint!
  29. @IBOutlet weak var sharedWithYouByView: UIView!
  30. @IBOutlet weak var sharedWithYouByImage: UIImageView!
  31. @IBOutlet weak var sharedWithYouByLabel: UILabel!
  32. @IBOutlet weak var searchFieldTopConstraint: NSLayoutConstraint!
  33. @IBOutlet weak var searchField: UITextField!
  34. @IBOutlet weak var shareLinkImage: UIImageView!
  35. @IBOutlet weak var shareLinkLabel: UILabel!
  36. @IBOutlet weak var shareInternalLinkImage: UIImageView!
  37. @IBOutlet weak var shareInternalLinkLabel: UILabel!
  38. @IBOutlet weak var shareInternalLinkDescription: UILabel!
  39. @IBOutlet weak var buttonInternalCopy: UIButton!
  40. @IBOutlet weak var buttonCopy: UIButton!
  41. @IBOutlet weak var buttonMenu: UIButton!
  42. @IBOutlet weak var tableView: UITableView!
  43. private let appDelegate = UIApplication.shared.delegate as! AppDelegate
  44. public var metadata: tableMetadata?
  45. public var sharingEnabled = true
  46. public var height: CGFloat = 0
  47. private var shareLinkMenuView: NCShareLinkMenuView?
  48. private var shareUserMenuView: NCShareUserMenuView?
  49. private var shareMenuViewWindow: UIView?
  50. private var dropDown = DropDown()
  51. private var networking: NCShareNetworking?
  52. override func viewDidLoad() {
  53. super.viewDidLoad()
  54. viewContainerConstraint.constant = height
  55. searchFieldTopConstraint.constant = 10
  56. searchField.placeholder = NSLocalizedString("_shareLinksearch_placeholder_", comment: "")
  57. shareLinkImage.image = NCShareCommon.shared.createLinkAvatar(imageName: "sharebylink", colorCircle: NCBrandColor.shared.brandElement)
  58. shareLinkLabel.text = NSLocalizedString("_share_link_", comment: "")
  59. buttonCopy.setImage(UIImage.init(named: "shareCopy")?.image(color: .gray, size: 50), for: .normal)
  60. shareInternalLinkImage.image = NCShareCommon.shared.createLinkAvatar(imageName: "shareInternalLink", colorCircle: .gray)
  61. shareInternalLinkLabel.text = NSLocalizedString("_share_internal_link_", comment: "")
  62. shareInternalLinkDescription.text = NSLocalizedString("_share_internal_link_des_", comment: "")
  63. buttonInternalCopy.setImage(UIImage.init(named: "shareCopy")?.image(color: .gray, size: 50), for: .normal)
  64. tableView.dataSource = self
  65. tableView.delegate = self
  66. tableView.allowsSelection = false
  67. tableView.register(UINib.init(nibName: "NCShareLinkCell", bundle: nil), forCellReuseIdentifier: "cellLink")
  68. tableView.register(UINib.init(nibName: "NCShareUserCell", bundle: nil), forCellReuseIdentifier: "cellUser")
  69. NotificationCenter.default.addObserver(self, selector: #selector(reloadData), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterReloadDataNCShare), object: nil)
  70. // Shared with you by ...
  71. if metadata!.ownerId != self.appDelegate.userId {
  72. searchFieldTopConstraint.constant = 65
  73. sharedWithYouByView.isHidden = false
  74. sharedWithYouByLabel.text = NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata!.ownerDisplayName
  75. sharedWithYouByImage.image = UIImage(named: "avatar")
  76. let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + metadata!.ownerId + ".png"
  77. if FileManager.default.fileExists(atPath: fileNameLocalPath) {
  78. if let image = UIImage(contentsOfFile: fileNameLocalPath) {
  79. sharedWithYouByImage.image = NCUtility.shared.createAvatar(image: image, size: 40)
  80. }
  81. } else {
  82. NCCommunication.shared.downloadAvatar(userId: metadata!.ownerId, fileNameLocalPath: fileNameLocalPath, size: NCGlobal.shared.avatarSize) { (account, data, errorCode, errorMessage) in
  83. if errorCode == 0 && account == self.appDelegate.account && UIImage(data: data!) != nil {
  84. if let image = UIImage(contentsOfFile: fileNameLocalPath) {
  85. self.sharedWithYouByImage.image = NCUtility.shared.createAvatar(image: image, size: 40)
  86. }
  87. }
  88. }
  89. }
  90. }
  91. reloadData()
  92. networking = NCShareNetworking.init(metadata: metadata!, urlBase: appDelegate.urlBase, view: self.view, delegate: self)
  93. if sharingEnabled {
  94. networking?.readShare()
  95. }
  96. // changeTheming
  97. NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
  98. changeTheming()
  99. }
  100. @objc func changeTheming() {
  101. view.backgroundColor = NCBrandColor.shared.backgroundView
  102. tableView.backgroundColor = NCBrandColor.shared.backgroundView
  103. tableView.reloadData()
  104. shareLinkLabel.textColor = NCBrandColor.shared.textView
  105. }
  106. @objc func reloadData() {
  107. let shares = NCManageDatabase.shared.getTableShares(metadata: metadata!)
  108. if shares.firstShareLink == nil {
  109. buttonMenu.setImage(UIImage.init(named: "shareAdd")?.image(color: .gray, size: 50), for: .normal)
  110. buttonCopy.isHidden = true
  111. } else {
  112. buttonMenu.setImage(UIImage.init(named: "shareMenu")?.image(color: .gray, size: 50), for: .normal)
  113. buttonCopy.isHidden = false
  114. }
  115. tableView.reloadData()
  116. }
  117. // MARK: - IBAction
  118. @IBAction func searchFieldDidEndOnExit(textField: UITextField) {
  119. guard let searchString = textField.text else { return }
  120. networking?.getSharees(searchString: searchString)
  121. }
  122. @IBAction func touchUpInsideButtonCopy(_ sender: Any) {
  123. guard let metadata = self.metadata else { return }
  124. let shares = NCManageDatabase.shared.getTableShares(metadata: metadata)
  125. tapCopy(with: shares.firstShareLink, sender: sender)
  126. }
  127. @IBAction func touchUpInsideButtonCopyInernalLink(_ sender: Any) {
  128. guard let metadata = self.metadata else { return }
  129. let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
  130. NCNetworking.shared.readFile(serverUrlFileName: serverUrlFileName, account: metadata.account) { (account, metadata, errorCode, errorDescription) in
  131. if errorCode == 0 && metadata != nil {
  132. let internalLink = self.appDelegate.urlBase + "/index.php/f/" + metadata!.fileId
  133. NCShareCommon.shared.copyLink(link: internalLink, viewController: self, sender: sender)
  134. } else {
  135. NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
  136. }
  137. }
  138. }
  139. @IBAction func touchUpInsideButtonMenu(_ sender: Any) {
  140. guard let metadata = self.metadata else { return }
  141. let isFilesSharingPublicPasswordEnforced = NCManageDatabase.shared.getCapabilitiesServerBool(account: metadata.account, elements: NCElementsJSON.shared.capabilitiesFileSharingPubPasswdEnforced, exists: false)
  142. let shares = NCManageDatabase.shared.getTableShares(metadata: metadata)
  143. if isFilesSharingPublicPasswordEnforced && shares.firstShareLink == nil {
  144. let alertController = UIAlertController(title: NSLocalizedString("_enforce_password_protection_", comment: ""), message: "", preferredStyle: .alert)
  145. alertController.addTextField { (textField) in
  146. textField.isSecureTextEntry = true
  147. }
  148. alertController.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .default) { (action:UIAlertAction) in })
  149. let okAction = UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default) { (action:UIAlertAction) in
  150. let password = alertController.textFields?.first?.text
  151. self.networking?.createShareLink(password: password ?? "")
  152. }
  153. alertController.addAction(okAction)
  154. self.present(alertController, animated: true, completion:nil)
  155. } else if shares.firstShareLink == nil {
  156. networking?.createShareLink(password: "")
  157. } else {
  158. tapMenu(with: shares.firstShareLink!, sender: sender)
  159. }
  160. }
  161. @objc func tapLinkMenuViewWindow(gesture: UITapGestureRecognizer) {
  162. shareLinkMenuView?.unLoad()
  163. shareLinkMenuView = nil
  164. shareUserMenuView?.unLoad()
  165. shareUserMenuView = nil
  166. }
  167. func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
  168. return gestureRecognizer.view == touch.view
  169. }
  170. func tapCopy(with tableShare: tableShare?, sender: Any) {
  171. if let link = tableShare?.url {
  172. NCShareCommon.shared.copyLink(link: link, viewController: self, sender: sender)
  173. }
  174. }
  175. func switchCanEdit(with tableShare: tableShare?, switch: Bool, sender: UISwitch) {
  176. guard let tableShare = tableShare else { return }
  177. guard let metadata = self.metadata else { return }
  178. let canShare = CCUtility.isPermission(toCanShare: tableShare.permissions)
  179. var permission: Int = 0
  180. if sender.isOn {
  181. permission = CCUtility.getPermissionsValue(byCanEdit: true, andCanCreate: true, andCanChange: true, andCanDelete: true, andCanShare: canShare, andIsFolder: metadata.directory)
  182. } else {
  183. permission = CCUtility.getPermissionsValue(byCanEdit: false, andCanCreate: false, andCanChange: false, andCanDelete: false, andCanShare: canShare, andIsFolder: metadata.directory)
  184. }
  185. networking?.updateShare(idShare: tableShare.idShare, password: nil, permission: permission, note: nil, expirationDate: nil, hideDownload: tableShare.hideDownload)
  186. }
  187. func tapMenu(with tableShare: tableShare?, sender: Any) {
  188. guard let tableShare = tableShare else { return }
  189. if tableShare.shareType == 3 {
  190. let views = NCShareCommon.shared.openViewMenuShareLink(shareViewController: self, tableShare: tableShare, metadata: metadata!)
  191. shareLinkMenuView = views.shareLinkMenuView
  192. shareMenuViewWindow = views.viewWindow
  193. let tap = UITapGestureRecognizer(target: self, action: #selector(tapLinkMenuViewWindow))
  194. tap.delegate = self
  195. shareMenuViewWindow?.addGestureRecognizer(tap)
  196. } else {
  197. let views = NCShareCommon.shared.openViewMenuUser(shareViewController: self, tableShare: tableShare, metadata: metadata!)
  198. shareUserMenuView = views.shareUserMenuView
  199. shareMenuViewWindow = views.viewWindow
  200. let tap = UITapGestureRecognizer(target: self, action: #selector(tapLinkMenuViewWindow))
  201. tap.delegate = self
  202. shareMenuViewWindow?.addGestureRecognizer(tap)
  203. }
  204. }
  205. /// MARK: - NCShareNetworkingDelegate
  206. func readShareCompleted() {
  207. NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataNCShare)
  208. }
  209. func shareCompleted() {
  210. NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataNCShare)
  211. }
  212. func unShareCompleted() { }
  213. func updateShareWithError(idShare: Int) { }
  214. func getSharees(sharees: [NCCommunicationSharee]?) {
  215. guard let sharees = sharees else { return }
  216. dropDown = DropDown()
  217. let appearance = DropDown.appearance()
  218. appearance.backgroundColor = NCBrandColor.shared.backgroundView
  219. appearance.cornerRadius = 10
  220. appearance.shadowColor = UIColor(white: 0.5, alpha: 1)
  221. appearance.shadowOpacity = 0.9
  222. appearance.shadowRadius = 25
  223. appearance.animationduration = 0.25
  224. appearance.textColor = .darkGray
  225. appearance.setupMaskedCorners([.layerMaxXMaxYCorner, .layerMinXMaxYCorner])
  226. for sharee in sharees {
  227. var label = sharee.label
  228. if sharee.shareType == NCShareCommon.shared.SHARE_TYPE_CIRCLE {
  229. label = label + " (" + sharee.circleInfo + ", " + sharee.circleOwner + ")"
  230. }
  231. dropDown.dataSource.append(label)
  232. }
  233. dropDown.anchorView = searchField
  234. dropDown.bottomOffset = CGPoint(x: 0, y: searchField.bounds.height)
  235. dropDown.width = searchField.bounds.width
  236. dropDown.direction = .bottom
  237. dropDown.cellNib = UINib(nibName: "NCShareUserDropDownCell", bundle: nil)
  238. dropDown.customCellConfiguration = { (index: Index, item: String, cell: DropDownCell) -> Void in
  239. guard let cell = cell as? NCShareUserDropDownCell else { return }
  240. let sharee = sharees[index]
  241. cell.imageItem.image = NCShareCommon.shared.getImageShareType(shareType: sharee.shareType)
  242. let status = NCUtility.shared.getUserStatus(userIcon: sharee.userIcon, userStatus: sharee.userStatus, userMessage: sharee.userMessage)
  243. cell.imageStatus.image = status.onlineStatus
  244. cell.status.text = status.statusMessage
  245. if cell.status.text?.count ?? 0 > 0 {
  246. cell.centerTitle.constant = -5
  247. } else {
  248. cell.centerTitle.constant = 0
  249. }
  250. let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(self.appDelegate.user, urlBase: self.appDelegate.urlBase)) + "-" + sharee.label + ".png"
  251. if FileManager.default.fileExists(atPath: fileNameLocalPath) {
  252. if let image = UIImage(contentsOfFile: fileNameLocalPath) {
  253. cell.imageItem.image = NCUtility.shared.createAvatar(image: image, size: 30)
  254. }
  255. } else {
  256. NCCommunication.shared.downloadAvatar(userId: sharee.shareWith, fileNameLocalPath: fileNameLocalPath, size: NCGlobal.shared.avatarSize) { (account, data, errorCode, errorMessage) in
  257. if errorCode == 0 && account == self.appDelegate.account && UIImage(data: data!) != nil {
  258. if let image = UIImage(contentsOfFile: fileNameLocalPath) {
  259. DispatchQueue.main.async {
  260. cell.imageItem.image = NCUtility.shared.createAvatar(image: image, size: 30)
  261. }
  262. }
  263. }
  264. }
  265. }
  266. cell.imageShareeType.image = NCShareCommon.shared.getImageShareType(shareType: sharee.shareType)
  267. }
  268. dropDown.selectionAction = { [weak self] (index, item) in
  269. let sharee = sharees[index]
  270. self!.networking?.createShare(shareWith: sharee.shareWith, shareType: sharee.shareType, metadata: self!.metadata!)
  271. }
  272. dropDown.show()
  273. }
  274. }
  275. // MARK: - UITableViewDelegate
  276. extension NCShare: UITableViewDelegate {
  277. func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  278. return 60
  279. }
  280. }
  281. // MARK: - UITableViewDataSource
  282. extension NCShare: UITableViewDataSource {
  283. func numberOfSections(in tableView: UITableView) -> Int {
  284. return 1
  285. }
  286. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  287. var numOfRows = 0
  288. let shares = NCManageDatabase.shared.getTableShares(metadata: metadata!)
  289. if shares.share != nil {
  290. numOfRows = shares.share!.count
  291. }
  292. return numOfRows
  293. }
  294. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  295. let shares = NCManageDatabase.shared.getTableShares(metadata: metadata!)
  296. let tableShare = shares.share![indexPath.row]
  297. // LINK
  298. if tableShare.shareType == 3 {
  299. if let cell = tableView.dequeueReusableCell(withIdentifier: "cellLink", for: indexPath) as? NCShareLinkCell {
  300. cell.tableShare = tableShare
  301. cell.delegate = self
  302. cell.labelTitle.text = NSLocalizedString("_share_link_", comment: "")
  303. cell.labelTitle.textColor = NCBrandColor.shared.textView
  304. return cell
  305. }
  306. } else {
  307. // USER
  308. if let cell = tableView.dequeueReusableCell(withIdentifier: "cellUser", for: indexPath) as? NCShareUserCell {
  309. cell.tableShare = tableShare
  310. cell.delegate = self
  311. cell.labelTitle.text = tableShare.shareWithDisplayname
  312. cell.labelTitle.textColor = NCBrandColor.shared.textView
  313. cell.labelCanEdit.text = NSLocalizedString("_share_permission_edit_", comment: "")
  314. cell.labelCanEdit.textColor = NCBrandColor.shared.textView
  315. cell.isUserInteractionEnabled = true
  316. cell.switchCanEdit.isHidden = false
  317. cell.labelCanEdit.isHidden = false
  318. cell.buttonMenu.isHidden = false
  319. cell.imageItem.image = NCShareCommon.shared.getImageShareType(shareType: tableShare.shareType)
  320. let status = NCUtility.shared.getUserStatus(userIcon: tableShare.userIcon, userStatus: tableShare.userStatus, userMessage: tableShare.userMessage)
  321. cell.imageStatus.image = status.onlineStatus
  322. cell.status.text = status.statusMessage
  323. let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + tableShare.shareWith + ".png"
  324. if FileManager.default.fileExists(atPath: fileNameLocalPath) {
  325. if let image = UIImage(contentsOfFile: fileNameLocalPath) {
  326. cell.imageItem.image = NCUtility.shared.createAvatar(image: image, size: 40)
  327. }
  328. } else {
  329. NCCommunication.shared.downloadAvatar(userId: tableShare.shareWith, fileNameLocalPath: fileNameLocalPath, size: NCGlobal.shared.avatarSize) { (account, data, errorCode, errorMessage) in
  330. if errorCode == 0 && account == self.appDelegate.account && UIImage(data: data!) != nil {
  331. if let image = UIImage(contentsOfFile: fileNameLocalPath) {
  332. cell.imageItem.image = NCUtility.shared.createAvatar(image: image, size: 40)
  333. }
  334. }
  335. }
  336. }
  337. if CCUtility.isAnyPermission(toEdit: tableShare.permissions) {
  338. cell.switchCanEdit.setOn(true, animated: false)
  339. } else {
  340. cell.switchCanEdit.setOn(false, animated: false)
  341. }
  342. // If the initiator or the recipient is not the current user, show the list of sharees without any options to edit it.
  343. if tableShare.uidOwner != self.appDelegate.userId && tableShare.uidFileOwner != self.appDelegate.userId {
  344. cell.isUserInteractionEnabled = false
  345. cell.switchCanEdit.isHidden = true
  346. cell.labelCanEdit.isHidden = true
  347. cell.buttonMenu.isHidden = true
  348. }
  349. return cell
  350. }
  351. }
  352. return UITableViewCell()
  353. }
  354. }
  355. // MARK: - NCShareLinkCell
  356. class NCShareLinkCell: UITableViewCell {
  357. @IBOutlet weak var imageItem: UIImageView!
  358. @IBOutlet weak var labelTitle: UILabel!
  359. @IBOutlet weak var buttonCopy: UIButton!
  360. @IBOutlet weak var buttonMenu: UIButton!
  361. private let iconShare: CGFloat = 200
  362. var tableShare: tableShare?
  363. var delegate: NCShareLinkCellDelegate?
  364. override func awakeFromNib() {
  365. super.awakeFromNib()
  366. imageItem.image = NCShareCommon.shared.createLinkAvatar(imageName: "sharebylink", colorCircle: NCBrandColor.shared.brandElement)
  367. buttonCopy.setImage(UIImage.init(named: "shareCopy")!.image(color: .gray, size: 50), for: .normal)
  368. buttonMenu.setImage(UIImage.init(named: "shareMenu")!.image(color: .gray, size: 50), for: .normal)
  369. }
  370. @IBAction func touchUpInsideCopy(_ sender: Any) {
  371. delegate?.tapCopy(with: tableShare, sender: sender)
  372. }
  373. @IBAction func touchUpInsideMenu(_ sender: Any) {
  374. delegate?.tapMenu(with: tableShare, sender: sender)
  375. }
  376. }
  377. protocol NCShareLinkCellDelegate {
  378. func tapCopy(with tableShare: tableShare?, sender: Any)
  379. func tapMenu(with tableShare: tableShare?, sender: Any)
  380. }
  381. // MARK: - NCShareUserCell
  382. class NCShareUserCell: UITableViewCell {
  383. @IBOutlet weak var imageItem: UIImageView!
  384. @IBOutlet weak var labelTitle: UILabel!
  385. @IBOutlet weak var labelCanEdit: UILabel!
  386. @IBOutlet weak var switchCanEdit: UISwitch!
  387. @IBOutlet weak var buttonMenu: UIButton!
  388. @IBOutlet weak var imageStatus: UIImageView!
  389. @IBOutlet weak var status: UILabel!
  390. var tableShare: tableShare?
  391. var delegate: NCShareUserCellDelegate?
  392. override func awakeFromNib() {
  393. super.awakeFromNib()
  394. switchCanEdit.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
  395. switchCanEdit.onTintColor = NCBrandColor.shared.brandElement
  396. buttonMenu.setImage(UIImage.init(named: "shareMenu")!.image(color: .gray, size: 50), for: .normal)
  397. }
  398. @IBAction func switchCanEditChanged(sender: UISwitch) {
  399. delegate?.switchCanEdit(with: tableShare, switch: sender.isOn, sender: sender)
  400. }
  401. @IBAction func touchUpInsideMenu(_ sender: Any) {
  402. delegate?.tapMenu(with: tableShare, sender: sender)
  403. }
  404. }
  405. protocol NCShareUserCellDelegate {
  406. func switchCanEdit(with tableShare: tableShare?, switch: Bool, sender: UISwitch)
  407. func tapMenu(with tableShare: tableShare?, sender: Any)
  408. }
  409. // MARK: - NCShareUserDropDownCell
  410. class NCShareUserDropDownCell: DropDownCell {
  411. @IBOutlet weak var imageItem: UIImageView!
  412. @IBOutlet weak var imageStatus: UIImageView!
  413. @IBOutlet weak var status: UILabel!
  414. @IBOutlet weak var imageShareeType: UIImageView!
  415. @IBOutlet weak var centerTitle: NSLayoutConstraint!
  416. }