|
@@ -3,7 +3,22 @@
|
|
|
// Share
|
|
|
//
|
|
|
// Created by Henrik Storch on 29.12.21.
|
|
|
-// Copyright © 2021 Marino Faggiana. All rights reserved.
|
|
|
+// Copyright © 2021 Henrik Storch. All rights reserved.
|
|
|
+//
|
|
|
+// Author Henrik Storch <henrik.storch@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
|
|
@@ -11,6 +26,7 @@ import NCCommunication
|
|
|
|
|
|
protocol NCShareCellDelegate: AnyObject {
|
|
|
func removeFile(named fileName: String)
|
|
|
+ func renameFile(named fileName: String)
|
|
|
}
|
|
|
|
|
|
class NCShareCell: UITableViewCell {
|
|
@@ -18,7 +34,7 @@ class NCShareCell: UITableViewCell {
|
|
|
@IBOutlet weak var fileNameCell: UILabel!
|
|
|
@IBOutlet weak var moreButton: UIButton!
|
|
|
@IBOutlet weak var sizeCell: UILabel!
|
|
|
- weak var delegate: NCShareCellDelegate?
|
|
|
+ weak var delegate: (NCShareCellDelegate & UIViewController)?
|
|
|
var fileName = ""
|
|
|
|
|
|
func setup(fileName: String) {
|
|
@@ -44,10 +60,22 @@ class NCShareCell: UITableViewCell {
|
|
|
let fileSize = NCUtilityFileSystem.shared.getFileSize(filePath: (NSTemporaryDirectory() + fileName))
|
|
|
sizeCell?.text = CCUtility.transformedSize(fileSize)
|
|
|
|
|
|
- moreButton?.setImage(NCUtility.shared.loadImage(named: "deleteScan").image(color: NCBrandColor.shared.label, size: 15), for: .normal)
|
|
|
+ moreButton?.setImage(NCUtility.shared.loadImage(named: "more").image(color: NCBrandColor.shared.label, size: 15), for: .normal)
|
|
|
}
|
|
|
|
|
|
@IBAction func buttonTapped(_ sender: Any) {
|
|
|
- delegate?.removeFile(named: fileName)
|
|
|
+ guard !fileName.isEmpty else { return }
|
|
|
+ let alertController = UIAlertController(title: "", message: fileName, preferredStyle: .alert)
|
|
|
+
|
|
|
+ alertController.addAction(UIAlertAction(title: NSLocalizedString("_rename_file_", comment: ""), style: .default) { _ in
|
|
|
+ self.delegate?.renameFile(named: self.fileName)
|
|
|
+ })
|
|
|
+
|
|
|
+ alertController.addAction(UIAlertAction(title: NSLocalizedString("_remove_file_", comment: ""), style: .default) { _ in
|
|
|
+ self.delegate?.removeFile(named: self.fileName)
|
|
|
+ })
|
|
|
+
|
|
|
+ alertController.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel) { _ in })
|
|
|
+ delegate?.present(alertController, animated: true, completion: nil)
|
|
|
}
|
|
|
}
|