AuthUIDelegate.swift 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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) || os(visionOS)
  15. import Foundation
  16. import UIKit
  17. /// A protocol to handle user interface interactions for Firebase Auth.
  18. ///
  19. /// This protocol is available on iOS, macOS Catalyst, and tvOS only.
  20. @objc(FIRAuthUIDelegate) public protocol AuthUIDelegate: NSObjectProtocol {
  21. /// If implemented, this method will be invoked when Firebase Auth needs to display a view
  22. /// controller.
  23. /// - Parameter viewControllerToPresent: The view controller to be presented.
  24. /// - Parameter flag: Decides whether the view controller presentation should be animated.
  25. /// - Parameter completion: The block to execute after the presentation finishes.
  26. /// This block has no return value and takes no parameters.
  27. @objc(presentViewController:animated:completion:)
  28. func present(_ viewControllerToPresent: UIViewController,
  29. animated flag: Bool,
  30. completion: (() -> Void)?)
  31. /// If implemented, this method will be invoked when Firebase Auth needs to display a view
  32. /// controller.
  33. /// - Parameter flag: Decides whether removing the view controller should be animated or not.
  34. /// - Parameter completion: The block to execute after the presentation finishes.
  35. /// This block has no return value and takes no parameters.
  36. @objc(dismissViewControllerAnimated:completion:)
  37. func dismiss(animated flag: Bool, completion: (() -> Void)?)
  38. }
  39. // Extension to support default argument variations.
  40. extension AuthUIDelegate {
  41. func present(_ viewControllerToPresent: UIViewController,
  42. animated flag: Bool,
  43. completion: (() -> Void)? = nil) {
  44. return present(viewControllerToPresent, animated: flag, completion: nil)
  45. }
  46. func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
  47. return dismiss(animated: flag, completion: nil)
  48. }
  49. }
  50. #endif