12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- //
- // DocumentActionViewController.swift
- // File Provider Extension UI
- //
- // Created by Marino Faggiana on 30/01/23.
- // Copyright © 2023 Marino Faggiana. All rights reserved.
- //
- import UIKit
- import FileProviderUI
- class DocumentActionViewController: FPUIActionExtensionViewController {
- @IBOutlet weak var identifierLabel: UILabel!
- @IBOutlet weak var cancelButton: UIButton!
- override func loadView() {
- super.loadView()
- view.backgroundColor = NCBrandColor.shared.brand
- identifierLabel.textColor = NCBrandColor.shared.brandText
- cancelButton.setTitleColor(NCBrandColor.shared.brandText, for: .normal)
- }
- override func prepare(forAction actionIdentifier: String, itemIdentifiers: [NSFileProviderItemIdentifier]) {
- }
- override func prepare(forError error: Error) {
- if let userInfo = (error as NSError).userInfo as NSDictionary?,
- let code = userInfo["code"] as? Int {
- if code == NCGlobal.shared.errorUnauthorizedFilesPasscode {
- identifierLabel?.text = NSLocalizedString("_unauthorizedFilesPasscode_", comment: "")
- }
- } else {
- identifierLabel?.text = error.localizedDescription
- }
- }
- @IBAction func doneButtonTapped(_ sender: Any) {
- // Perform the action and call the completion block. If an unrecoverable error occurs you must still call the completion block with an error. Use the error code FPUIExtensionErrorCode.failed to signal the failure.
- extensionContext.completeRequest()
- }
- @IBAction func cancelButtonTapped(_ sender: Any) {
- extensionContext.cancelRequest(withError: NSError(domain: FPUIErrorDomain, code: Int(FPUIExtensionErrorCode.userCancelled.rawValue), userInfo: nil))
- }
- }
|