AlertAction.swift 764 B

123456789101112131415161718192021
  1. /// An alert action button.
  2. ///
  3. /// Only backends should interface with this type directly. This exists to avoid
  4. /// having to expose internal details of ``Button``, since breaking `Button`'s
  5. /// API would have much more wide-reaching impacts than breaking this
  6. /// single-purpose API.
  7. ///
  8. /// # See Also
  9. /// - ``View/alert(_:isPresented:actions:)``
  10. public struct AlertAction: Sendable {
  11. /// The default alert action.
  12. ///
  13. /// Consists of a button labeled "OK" with no action (other than dismissing
  14. /// the alert, which is implicit).
  15. public static let `default` = AlertAction(label: "OK", action: {})
  16. /// The button's label.
  17. public var label: String
  18. /// The button's action.
  19. public var action: @MainActor @Sendable () -> Void
  20. }