ScenePhase.swift 774 B

123456789101112131415161718192021222324
  1. /// A phase of a scene's lifecycle.
  2. public struct ScenePhase: Hashable, Sendable {
  3. private enum Phase: Hashable, Sendable {
  4. case active
  5. case inactive
  6. }
  7. private var phase: Phase
  8. /// The scene is currently active.
  9. ///
  10. /// This indicates that the scene has focus and can recieve input events.
  11. public static let active = Self(phase: .active)
  12. /// The scene is currently inactive.
  13. ///
  14. /// This indicates that the scene does not have focus and does not recieve
  15. /// input events. The scene may or may not still be visible to the user.
  16. public static let inactive = Self(phase: .inactive)
  17. }
  18. extension ScenePhase: CustomStringConvertible {
  19. public var description: String {
  20. String(describing: phase)
  21. }
  22. }