DocumentActionViewController.swift 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // DocumentActionViewController.swift
  3. // File Provider ExtensionUI
  4. //
  5. // Created by Marino Faggiana on 26/06/18.
  6. // Copyright © 2018 TWS. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  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 FileProviderUI
  25. class DocumentActionViewController: FPUIActionExtensionViewController {
  26. @IBOutlet weak var identifierLabel: UILabel!
  27. @IBOutlet weak var actionTypeLabel: UILabel!
  28. override func prepare(forAction actionIdentifier: String, itemIdentifiers: [NSFileProviderItemIdentifier]) {
  29. identifierLabel?.text = actionIdentifier
  30. actionTypeLabel?.text = "Custom action"
  31. }
  32. override func prepare(forError error: Error) {
  33. identifierLabel?.text = error.localizedDescription
  34. actionTypeLabel?.text = "Authenticate"
  35. }
  36. @IBAction func doneButtonTapped(_ sender: Any) {
  37. // 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.
  38. extensionContext.completeRequest()
  39. }
  40. @IBAction func cancelButtonTapped(_ sender: Any) {
  41. extensionContext.cancelRequest(withError: NSError(domain: FPUIErrorDomain, code: Int(FPUIExtensionErrorCode.userCancelled.rawValue), userInfo: nil))
  42. }
  43. }