123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627 |
- //
- // NCShare.swift
- // Nextcloud
- //
- // Created by Marino Faggiana on 17/07/2019.
- // Copyright © 2019 Marino Faggiana. All rights reserved.
- //
- // Author Marino Faggiana <marino.faggiana@nextcloud.com>
- //
- // This program is free software: you can redistribute it and/or modify
- // it under the terms of the GNU General Public License as published by
- // the Free Software Foundation, either version 3 of the License, or
- // (at your option) any later version.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU General Public License for more details.
- //
- // You should have received a copy of the GNU General Public License
- // along with this program. If not, see <http://www.gnu.org/licenses/>.
- //
- import UIKit
- import Parchment
- import DropDown
- import NCCommunication
- import MarqueeLabel
- class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDelegate, NCShareUserCellDelegate, NCShareNetworkingDelegate {
-
- @IBOutlet weak var viewContainerConstraint: NSLayoutConstraint!
- @IBOutlet weak var sharedWithYouByView: UIView!
- @IBOutlet weak var sharedWithYouByImage: UIImageView!
- @IBOutlet weak var sharedWithYouByLabel: UILabel!
- @IBOutlet weak var sharedWithYouByNoteImage: UIImageView!
- @IBOutlet weak var sharedWithYouByNote: MarqueeLabel!
- @IBOutlet weak var searchFieldTopConstraint: NSLayoutConstraint!
- @IBOutlet weak var searchField: UITextField!
- @IBOutlet weak var shareLinkImage: UIImageView!
- @IBOutlet weak var shareLinkLabel: UILabel!
- @IBOutlet weak var shareInternalLinkImage: UIImageView!
- @IBOutlet weak var shareInternalLinkLabel: UILabel!
- @IBOutlet weak var shareInternalLinkDescription: UILabel!
- @IBOutlet weak var buttonInternalCopy: UIButton!
- @IBOutlet weak var buttonCopy: UIButton!
- @IBOutlet weak var buttonMenu: UIButton!
- @IBOutlet weak var tableView: UITableView!
-
- private let appDelegate = UIApplication.shared.delegate as! AppDelegate
- public var metadata: tableMetadata?
- public var sharingEnabled = true
- public var height: CGFloat = 0
-
- private var shareLinkMenuView: NCShareLinkMenuView?
- private var shareUserMenuView: NCShareUserMenuView?
- private var shareMenuViewWindow: UIView?
- private var dropDown = DropDown()
- private var networking: NCShareNetworking?
-
- // MARK: - View Life Cycle
- override func viewDidLoad() {
- super.viewDidLoad()
-
- view.backgroundColor = NCBrandColor.shared.systemBackground
- viewContainerConstraint.constant = height
- searchFieldTopConstraint.constant = 10
-
- searchField.placeholder = NSLocalizedString("_shareLinksearch_placeholder_", comment: "")
-
- shareLinkImage.image = NCShareCommon.shared.createLinkAvatar(imageName: "sharebylink", colorCircle: NCBrandColor.shared.brandElement)
- shareLinkLabel.text = NSLocalizedString("_share_link_", comment: "")
- shareLinkLabel.textColor = NCBrandColor.shared.label
- buttonCopy.setImage(UIImage.init(named: "shareCopy")?.image(color: .gray, size: 50), for: .normal)
- shareInternalLinkImage.image = NCShareCommon.shared.createLinkAvatar(imageName: "shareInternalLink", colorCircle: .gray)
- shareInternalLinkLabel.text = NSLocalizedString("_share_internal_link_", comment: "")
- shareInternalLinkDescription.text = NSLocalizedString("_share_internal_link_des_", comment: "")
- buttonInternalCopy.setImage(UIImage.init(named: "shareCopy")?.image(color: .gray, size: 50), for: .normal)
- tableView.dataSource = self
- tableView.delegate = self
- tableView.allowsSelection = false
- tableView.backgroundColor = NCBrandColor.shared.systemBackground
- tableView.register(UINib.init(nibName: "NCShareLinkCell", bundle: nil), forCellReuseIdentifier: "cellLink")
- tableView.register(UINib.init(nibName: "NCShareUserCell", bundle: nil), forCellReuseIdentifier: "cellUser")
-
- NotificationCenter.default.addObserver(self, selector: #selector(reloadData), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterReloadDataNCShare), object: nil)
-
- // Shared with you by ...
- if metadata!.ownerId != "" && metadata!.ownerId != self.appDelegate.userId {
-
- searchFieldTopConstraint.constant = 65
- sharedWithYouByView.isHidden = false
- sharedWithYouByLabel.text = NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata!.ownerDisplayName
- sharedWithYouByImage.image = UIImage(named: "avatar")?.imageColor(NCBrandColor.shared.label)
-
- if metadata?.note.count ?? 0 > 0 {
- searchFieldTopConstraint.constant = 95
- sharedWithYouByNoteImage.isHidden = false
- sharedWithYouByNoteImage.image = NCUtility.shared.loadImage(named: "note.text", color: .gray)
- sharedWithYouByNote.isHidden = false
- sharedWithYouByNote.text = metadata?.note
- sharedWithYouByNote.textColor = NCBrandColor.shared.label
- sharedWithYouByNote.trailingBuffer = sharedWithYouByNote.frame.width
- } else {
- sharedWithYouByNoteImage.isHidden = true
- sharedWithYouByNote.isHidden = true
- }
-
- let fileName = String(CCUtility.getUserUrlBase(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + metadata!.ownerId + ".png"
-
- if let image = NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) {
-
- sharedWithYouByImage.image = image
-
- } else {
-
- let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
- let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
-
- NCCommunication.shared.downloadAvatar(user: metadata!.ownerId, fileNameLocalPath: fileNameLocalPath, sizeImage: NCGlobal.shared.avatarSize, avatarSizeRounded: NCGlobal.shared.avatarSizeRounded, etag: etag) { (account, imageAvatar, imageOriginal, etag, errorCode, errorMessage) in
-
- if errorCode == 0, let etag = etag, let imageAvatar = imageAvatar {
-
- NCManageDatabase.shared.addAvatar(fileName: fileName, etag: etag)
- self.sharedWithYouByImage.image = imageAvatar
-
- } else if errorCode == NCGlobal.shared.errorNotModified, let imageAvatar = NCManageDatabase.shared.setAvatarLoaded(fileName: fileName) {
-
- self.sharedWithYouByImage.image = imageAvatar
- }
- }
- }
- }
-
- reloadData()
-
- networking = NCShareNetworking.init(metadata: metadata!, urlBase: appDelegate.urlBase, view: self.view, delegate: self)
- if sharingEnabled {
- networking?.readShare()
- }
-
- // changeTheming
- NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(changePermissions(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterShareChangePermissions), object: nil)
-
- changeTheming()
- }
-
- // MARK: - Notification Center
-
- @objc func changeTheming() {
- tableView.reloadData()
- }
-
- @objc func changePermissions(_ notification: NSNotification) {
-
- if let userInfo = notification.userInfo as NSDictionary? {
- if let idShare = userInfo["idShare"] as? Int, let permissions = userInfo["permissions"] as? Int, let hideDownload = userInfo["hideDownload"] as? Bool {
- networking?.updateShare(idShare: idShare, password: nil, permissions: permissions, note: nil, label: nil, expirationDate: nil, hideDownload: hideDownload)
- }
- }
- }
- // MARK: -
-
- @objc func reloadData() {
- let shares = NCManageDatabase.shared.getTableShares(metadata: metadata!)
- if shares.firstShareLink == nil {
- buttonMenu.setImage(UIImage.init(named: "shareAdd")?.image(color: .gray, size: 50), for: .normal)
- buttonCopy.isHidden = true
- } else {
- buttonMenu.setImage(UIImage.init(named: "shareMenu")?.image(color: .gray, size: 50), for: .normal)
- buttonCopy.isHidden = false
-
- shareLinkLabel.text = NSLocalizedString("_share_link_", comment: "")
- if shares.firstShareLink?.label.count ?? 0 > 0 {
- if let shareLinkLabel = shareLinkLabel {
- if let label = shares.firstShareLink?.label {
- shareLinkLabel.text = NSLocalizedString("_share_link_", comment: "") + " (" + label + ")"
- }
- }
- }
- }
- tableView.reloadData()
- }
-
- // MARK: - IBAction
- @IBAction func searchFieldDidEndOnExit(textField: UITextField) {
-
- guard let searchString = textField.text else { return }
- networking?.getSharees(searchString: searchString)
- }
-
- @IBAction func touchUpInsideButtonCopy(_ sender: Any) {
-
- guard let metadata = self.metadata else { return }
- let shares = NCManageDatabase.shared.getTableShares(metadata: metadata)
- tapCopy(with: shares.firstShareLink, sender: sender)
- }
-
- @IBAction func touchUpInsideButtonCopyInernalLink(_ sender: Any) {
-
- guard let metadata = self.metadata else { return }
-
- let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
- NCNetworking.shared.readFile(serverUrlFileName: serverUrlFileName, account: metadata.account) { (account, metadata, errorCode, errorDescription) in
- if errorCode == 0 && metadata != nil {
- let internalLink = self.appDelegate.urlBase + "/index.php/f/" + metadata!.fileId
- NCShareCommon.shared.copyLink(link: internalLink, viewController: self, sender: sender)
- } else {
- NCContentPresenter.shared.messageNotification("_share_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
- }
- }
- }
-
- @IBAction func touchUpInsideButtonMenu(_ sender: Any) {
- guard let metadata = self.metadata else { return }
- let isFilesSharingPublicPasswordEnforced = NCManageDatabase.shared.getCapabilitiesServerBool(account: metadata.account, elements: NCElementsJSON.shared.capabilitiesFileSharingPubPasswdEnforced, exists: false)
- let shares = NCManageDatabase.shared.getTableShares(metadata: metadata)
- if isFilesSharingPublicPasswordEnforced && shares.firstShareLink == nil {
- let alertController = UIAlertController(title: NSLocalizedString("_enforce_password_protection_", comment: ""), message: "", preferredStyle: .alert)
- alertController.addTextField { (textField) in
- textField.isSecureTextEntry = true
- }
- alertController.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .default) { (action:UIAlertAction) in })
- let okAction = UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default) { (action:UIAlertAction) in
- let password = alertController.textFields?.first?.text
- self.networking?.createShareLink(password: password ?? "")
- }
-
- alertController.addAction(okAction)
-
- self.present(alertController, animated: true, completion:nil)
- } else if shares.firstShareLink == nil {
- networking?.createShareLink(password: "")
- } else {
- tapMenu(with: shares.firstShareLink!, sender: sender)
- }
- }
-
- @objc func tapLinkMenuViewWindow(gesture: UITapGestureRecognizer) {
- shareLinkMenuView?.unLoad()
- shareLinkMenuView = nil
- shareUserMenuView?.unLoad()
- shareUserMenuView = nil
- }
-
- func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
- return gestureRecognizer.view == touch.view
- }
-
- func tapCopy(with tableShare: tableShare?, sender: Any) {
-
- if let link = tableShare?.url {
- NCShareCommon.shared.copyLink(link: link, viewController: self, sender: sender)
- }
- }
-
- func tapMenu(with tableShare: tableShare?, sender: Any) {
-
- guard let tableShare = tableShare else { return }
- if tableShare.shareType == 3 {
- let views = NCShareCommon.shared.openViewMenuShareLink(shareViewController: self, tableShare: tableShare, metadata: metadata!)
- shareLinkMenuView = views.shareLinkMenuView
- shareMenuViewWindow = views.viewWindow
-
- let tap = UITapGestureRecognizer(target: self, action: #selector(tapLinkMenuViewWindow))
- tap.delegate = self
- shareMenuViewWindow?.addGestureRecognizer(tap)
- } else {
- let views = NCShareCommon.shared.openViewMenuUser(shareViewController: self, tableShare: tableShare, metadata: metadata!)
- shareUserMenuView = views.shareUserMenuView
- shareMenuViewWindow = views.viewWindow
-
- let tap = UITapGestureRecognizer(target: self, action: #selector(tapLinkMenuViewWindow))
- tap.delegate = self
- shareMenuViewWindow?.addGestureRecognizer(tap)
- }
- }
- func quickStatus(with tableShare: tableShare?, sender: Any) {
- guard let tableShare = tableShare else { return }
- if tableShare.shareType != NCGlobal.shared.permissionDefaultFileRemoteShareNoSupportShareOption {
- //self.quickStatusTableShare = tableShare
- let quickStatusMenu = NCShareQuickStatusMenu()
- quickStatusMenu.toggleMenu(viewController: self, directory: metadata!.directory, tableShare: tableShare)
- }
- }
- // MARK: - NCShareNetworkingDelegate
-
- func readShareCompleted() {
- NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataNCShare)
- }
-
- func shareCompleted() {
- NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataNCShare)
- }
-
- func unShareCompleted() { }
-
- func updateShareWithError(idShare: Int) {
- self.reloadData()
- }
-
- func getSharees(sharees: [NCCommunicationSharee]?) {
-
- guard let sharees = sharees else { return }
- dropDown = DropDown()
- let appearance = DropDown.appearance()
-
- appearance.backgroundColor = NCBrandColor.shared.systemBackground
- appearance.cornerRadius = 10
- appearance.shadowColor = UIColor(white: 0.5, alpha: 1)
- appearance.shadowOpacity = 0.9
- appearance.shadowRadius = 25
- appearance.animationduration = 0.25
- appearance.textColor = .darkGray
- appearance.setupMaskedCorners([.layerMaxXMaxYCorner, .layerMinXMaxYCorner])
-
- for sharee in sharees {
- var label = sharee.label
- if sharee.shareType == NCShareCommon.shared.SHARE_TYPE_CIRCLE {
- label = label + " (" + sharee.circleInfo + ", " + sharee.circleOwner + ")"
- }
- dropDown.dataSource.append(label)
- }
-
- dropDown.anchorView = searchField
- dropDown.bottomOffset = CGPoint(x: 0, y: searchField.bounds.height)
- dropDown.width = searchField.bounds.width
- dropDown.direction = .bottom
-
- dropDown.cellNib = UINib(nibName: "NCShareUserDropDownCell", bundle: nil)
- dropDown.customCellConfiguration = { (index: Index, item: String, cell: DropDownCell) -> Void in
- guard let cell = cell as? NCShareUserDropDownCell else { return }
- let sharee = sharees[index]
- cell.imageItem.image = NCShareCommon.shared.getImageShareType(shareType: sharee.shareType)
- cell.imageShareeType.image = NCShareCommon.shared.getImageShareType(shareType: sharee.shareType)
- let status = NCUtility.shared.getUserStatus(userIcon: sharee.userIcon, userStatus: sharee.userStatus, userMessage: sharee.userMessage)
- cell.imageStatus.image = status.onlineStatus
- cell.status.text = status.statusMessage
- if cell.status.text?.count ?? 0 > 0 {
- cell.centerTitle.constant = -5
- } else {
- cell.centerTitle.constant = 0
- }
-
- let fileName = String(CCUtility.getUserUrlBase(self.appDelegate.user, urlBase: self.appDelegate.urlBase)) + "-" + sharee.shareWith + ".png"
-
- if let image = NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) {
-
- cell.imageItem.image = image
-
- } else {
-
- let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
- let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
- NCCommunication.shared.downloadAvatar(user: sharee.shareWith, fileNameLocalPath: fileNameLocalPath, sizeImage: NCGlobal.shared.avatarSize, avatarSizeRounded: NCGlobal.shared.avatarSizeRounded, etag: etag) { (account, imageAvatar, imageOriginal, etag, errorCode, errorMessage) in
-
- if errorCode == 0, let etag = etag, let imageAvatar = imageAvatar {
-
- NCManageDatabase.shared.addAvatar(fileName: fileName, etag: etag)
- cell.imageItem.image = imageAvatar
-
- } else if errorCode == NCGlobal.shared.errorNotModified, let imageAvatar = NCManageDatabase.shared.setAvatarLoaded(fileName: fileName) {
-
- cell.imageItem.image = imageAvatar
- }
- }
- }
- }
-
- dropDown.selectionAction = { [weak self] (index, item) in
- let sharee = sharees[index]
- self!.networking?.createShare(shareWith: sharee.shareWith, shareType: sharee.shareType, metadata: self!.metadata!)
- }
-
- dropDown.show()
- }
- }
- // MARK: - UITableViewDelegate
- extension NCShare: UITableViewDelegate {
-
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return 70
- }
- }
- // MARK: - UITableViewDataSource
- extension NCShare: UITableViewDataSource {
-
- func numberOfSections(in tableView: UITableView) -> Int {
- return 1
- }
-
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-
- var numOfRows = 0
- let shares = NCManageDatabase.shared.getTableShares(metadata: metadata!)
-
- if shares.share != nil {
- numOfRows = shares.share!.count
- }
-
- return numOfRows
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-
- let shares = NCManageDatabase.shared.getTableShares(metadata: metadata!)
- let tableShare = shares.share![indexPath.row]
-
- // LINK
- if tableShare.shareType == 3 {
- if let cell = tableView.dequeueReusableCell(withIdentifier: "cellLink", for: indexPath) as? NCShareLinkCell {
- cell.tableShare = tableShare
- cell.delegate = self
- cell.labelTitle.text = NSLocalizedString("_share_link_", comment: "")
- if tableShare.label.count > 0 {
- cell.labelTitle.text = NSLocalizedString("_share_link_", comment: "") + " (" + tableShare.label + ")"
- }
- cell.labelTitle.textColor = NCBrandColor.shared.label
- return cell
- }
- } else {
- // USER
- if let cell = tableView.dequeueReusableCell(withIdentifier: "cellUser", for: indexPath) as? NCShareUserCell {
-
- cell.tableShare = tableShare
- cell.delegate = self
- cell.labelTitle.text = tableShare.shareWithDisplayname
- cell.labelTitle.textColor = NCBrandColor.shared.label
- cell.isUserInteractionEnabled = true
- cell.labelQuickStatus.isHidden = false
- cell.imageDownArrow.isHidden = false
- cell.buttonMenu.isHidden = false
- cell.imageItem.image = NCShareCommon.shared.getImageShareType(shareType: tableShare.shareType)
-
- let status = NCUtility.shared.getUserStatus(userIcon: tableShare.userIcon, userStatus: tableShare.userStatus, userMessage: tableShare.userMessage)
- cell.imageStatus.image = status.onlineStatus
- cell.status.text = status.statusMessage
-
- let fileName = String(CCUtility.getUserUrlBase(appDelegate.user, urlBase: appDelegate.urlBase)) + "-" + tableShare.shareWith + ".png"
-
- NCOperationQueue.shared.downloadAvatar(user: tableShare.shareWith, fileName: fileName, placeholder: UIImage(named: "avatar"), cell: cell, view: tableView)
-
- // If the initiator or the recipient is not the current user, show the list of sharees without any options to edit it.
- if tableShare.uidOwner != self.appDelegate.userId && tableShare.uidFileOwner != self.appDelegate.userId {
- cell.isUserInteractionEnabled = false
- cell.labelQuickStatus.isHidden = true
- cell.imageDownArrow.isHidden = true
- cell.buttonMenu.isHidden = true
- }
-
- cell.btnQuickStatus.setTitle("", for: .normal)
- cell.btnQuickStatus.contentHorizontalAlignment = .left
-
- if tableShare.permissions == NCGlobal.shared.permissionCreateShare {
- cell.labelQuickStatus.text = NSLocalizedString("_share_file_drop_", comment: "")
- } else {
- // Read Only
- if CCUtility.isAnyPermission(toEdit: tableShare.permissions) {
- cell.labelQuickStatus.text = NSLocalizedString("_share_editing_", comment: "")
- } else {
- cell.labelQuickStatus.text = NSLocalizedString("_share_read_only_", comment: "")
- }
- }
- return cell
- }
- }
-
- return UITableViewCell()
- }
- }
- // MARK: - NCShareLinkCell
- class NCShareLinkCell: UITableViewCell {
-
- @IBOutlet weak var imageItem: UIImageView!
- @IBOutlet weak var labelTitle: UILabel!
- @IBOutlet weak var buttonCopy: UIButton!
- @IBOutlet weak var buttonMenu: UIButton!
-
- private let iconShare: CGFloat = 200
-
- var tableShare: tableShare?
- var delegate: NCShareLinkCellDelegate?
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- imageItem.image = NCShareCommon.shared.createLinkAvatar(imageName: "sharebylink", colorCircle: NCBrandColor.shared.brandElement)
- buttonCopy.setImage(UIImage.init(named: "shareCopy")!.image(color: .gray, size: 50), for: .normal)
- buttonMenu.setImage(UIImage.init(named: "shareMenu")!.image(color: .gray, size: 50), for: .normal)
- }
-
- @IBAction func touchUpInsideCopy(_ sender: Any) {
- delegate?.tapCopy(with: tableShare, sender: sender)
- }
-
- @IBAction func touchUpInsideMenu(_ sender: Any) {
- delegate?.tapMenu(with: tableShare, sender: sender)
- }
- }
- protocol NCShareLinkCellDelegate {
- func tapCopy(with tableShare: tableShare?, sender: Any)
- func tapMenu(with tableShare: tableShare?, sender: Any)
- }
- // MARK: - NCShareUserCell
- class NCShareUserCell: UITableViewCell, NCCellProtocol {
-
- @IBOutlet weak var imageItem: UIImageView!
- @IBOutlet weak var labelTitle: UILabel!
- @IBOutlet weak var buttonMenu: UIButton!
- @IBOutlet weak var imageStatus: UIImageView!
- @IBOutlet weak var status: UILabel!
- @IBOutlet weak var btnQuickStatus: UIButton!
- @IBOutlet weak var labelQuickStatus: UILabel!
- @IBOutlet weak var imageDownArrow: UIImageView!
-
- var tableShare: tableShare?
- var delegate: NCShareUserCellDelegate?
-
- var fileAvatarImageView: UIImageView? {
- get{
- return imageItem
- }
- }
- var fileObjectId: String? {
- get {
- return nil
- }
- }
- var filePreviewImageView : UIImageView? {
- get{
- return nil
- }
- }
- var fileUser: String? {
- get{
- return tableShare?.shareWith
- }
- }
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- buttonMenu.setImage(UIImage.init(named: "shareMenu")!.image(color: .gray, size: 50), for: .normal)
- labelQuickStatus.textColor = NCBrandColor.shared.customer
- imageDownArrow.image = NCUtility.shared.loadImage(named: "arrowtriangle.down.fill", color: NCBrandColor.shared.customer)
- }
-
- @IBAction func touchUpInsideMenu(_ sender: Any) {
- delegate?.tapMenu(with: tableShare, sender: sender)
- }
-
- @IBAction func quickStatusClicked(_ sender: Any) {
- delegate?.quickStatus(with: tableShare, sender: sender)
- }
- }
- protocol NCShareUserCellDelegate {
- func tapMenu(with tableShare: tableShare?, sender: Any)
- func quickStatus(with tableShare: tableShare?, sender: Any)
- }
- // MARK: - NCShareUserDropDownCell
- class NCShareUserDropDownCell: DropDownCell, NCCellProtocol {
-
- @IBOutlet weak var imageItem: UIImageView!
- @IBOutlet weak var imageStatus: UIImageView!
- @IBOutlet weak var status: UILabel!
- @IBOutlet weak var imageShareeType: UIImageView!
- @IBOutlet weak var centerTitle: NSLayoutConstraint!
-
- private var user: String = ""
-
- var fileAvatarImageView: UIImageView? {
- get {
- return imageItem
- }
- }
- var fileObjectId: String? {
- get {
- return nil
- }
- }
- var filePreviewImageView: UIImageView? {
- get {
- return nil
- }
- }
- var fileUser: String? {
- get {
- return user
- }
- set {
- user = newValue ?? ""
- }
- }
- }
|