AuthUIDelegate.swift 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2023 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #if os(iOS) || os(tvOS)
  15. import Foundation
  16. import UIKit
  17. /** @protocol AuthUIDelegate
  18. @brief A protocol to handle user interface interactions for Firebase Auth.
  19. This protocol is available on iOS, macOS Catalyst, and tvOS only.
  20. */
  21. @objc(FIRAuthUIDelegate) public protocol AuthUIDelegate: NSObjectProtocol {
  22. /** @fn presentViewController:animated:completion:
  23. @brief If implemented, this method will be invoked when Firebase Auth needs to display a view
  24. controller.
  25. @param viewControllerToPresent The view controller to be presented.
  26. @param flag Decides whether the view controller presentation should be animated or not.
  27. @param completion The block to execute after the presentation finishes. This block has no return
  28. value and takes no parameters.
  29. */
  30. @objc(presentViewController:animated:completion:)
  31. func present(_ viewControllerToPresent: UIViewController,
  32. animated flag: Bool,
  33. completion: (() -> Void)?)
  34. /** @fn dismissViewControllerAnimated:completion:
  35. @brief If implemented, this method will be invoked when Firebase Auth needs to display a view
  36. controller.
  37. @param flag Decides whether removing the view controller should be animated or not.
  38. @param completion The block to execute after the presentation finishes. This block has no return
  39. value and takes no parameters.
  40. */
  41. @objc(dismissViewControllerAnimated:completion:)
  42. func dismiss(animated flag: Bool, completion: (() -> Void)?)
  43. }
  44. // Extension to support default argument variations.
  45. extension AuthUIDelegate {
  46. func present(_ viewControllerToPresent: UIViewController,
  47. animated flag: Bool,
  48. completion: (() -> Void)? = nil) {
  49. return present(viewControllerToPresent, animated: flag, completion: nil)
  50. }
  51. func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
  52. return dismiss(animated: flag, completion: nil)
  53. }
  54. }
  55. #endif