NCShare.swift 24 KB

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