// // NCShareComments.swift // Nextcloud // // Created by Marino Faggiana on 28/07/2019. // Copyright © 2019 Marino Faggiana. All rights reserved. // // Author Marino Faggiana // // 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 . // import Foundation class NCShareComments: UIViewController { @IBOutlet weak var viewContainerConstraint: NSLayoutConstraint! @IBOutlet weak var tableView: UITableView! @IBOutlet weak var newCommentField: UITextField! private let appDelegate = UIApplication.shared.delegate as! AppDelegate var metadata: tableMetadata? public var height: CGFloat = 0 override func viewDidLoad() { super.viewDidLoad() viewContainerConstraint.constant = height guard let metadata = self.metadata else { return } OCNetworking.sharedManager()?.getCommentsWithAccount(appDelegate.activeAccount, fileID: metadata.fileID, completion: { (account, items, message, errorCode) in if errorCode == 0 { let itemsNCComments = items as! [NCComments] NCManageDatabase.sharedInstance.addComments(itemsNCComments, account: metadata.account, fileID: metadata.fileID) } else { self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode) } }) } } // MARK: - NCShareCommentsCell class NCShareCommentsCell: UITableViewCell { @IBOutlet weak var imageItem: UIImageView! @IBOutlet weak var labelUser: UILabel! @IBOutlet weak var buttonMenu: UIButton! @IBOutlet weak var labelDate: UILabel! @IBOutlet weak var labelMessage: UILabel! var tableComments: tableComments? var delegate: NCShareCommentsCellDelegate? override func awakeFromNib() { super.awakeFromNib() buttonMenu.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "shareMenu"), width:100, height: 100, color: UIColor.gray), for: .normal) } @IBAction func touchUpInsideMenu(_ sender: Any) { delegate?.tapMenu(with: tableComments, sender: sender) } } protocol NCShareCommentsCellDelegate { func tapMenu(with tableComments: tableComments?, sender: Any) }